tcp - how to transfer binary data through tcpip in matlab -


i have read sample provided matlab. code is

client:

data = single(1024); t = tcpip('127.0.0.1', 2688, 'networkrole', 'client'); set(t,'terminator',''); fopen(t); pause(0.1) fwrite(t, data, 'float32'); fclose(t); 

server:

t = tcpip('0.0.0.0', 2688, 'networkrole', 'server'); set(t,'inputbuffersize',4096); set(t,'terminator','');  fopen(t); while t.bytesavailable==0     pause(0.1);     disp('no data'); end data = fread(t, 1,'float32') whos data 

the output is

data =          1024  name      size            bytes  class     attributes  data      1x1                 8  double             

it seems data correct value incorrect type. documentation of fread says:

 ...by default, numeric values returned in double-precision arrays... 

i want ask if there efficient way change type of return array true type instead of converting "single(..)".


Comments

Popular posts from this blog

asynchronous - C# WinSCP .NET assembly: How to upload multiple files asynchronously -

aws api gateway - SerializationException in posting new Records via Dynamodb Proxy Service in API -

asp.net - Problems sending emails from forum -