look at this, i tested it and it's working http://www.mathworks.com/matlabcentral/fileexchange/42567-matlab-and-labview-data-exchange-over-tcp-ip
Read data from TCP/IP from labview
3 次查看(过去 30 天)
显示 更早的评论
I send the data using a tcpip connetion in labview. The data I write looks like this(4 bytes): If I wanted to send decimal 16, it would send the string '0000 0010' in labview. Now I want to read this value ('0000 0010') in matlab. I have tried:
fread(Client,4)
So this would give a 4x1 array of [0;0;0;16].
I have found a way of converting this to the hex format and then into the decimal format i need, but i think there is a better way. any suggestions?
val = fread(Client,4);
val = dec2hex(val );
val = transpose(val );
val = reshape(val ,1,8);
val = val (find(~isspace(val )));
val = hex2dec(val );
I should mention that in labview if I want to receive the data all I do is use a typecast function (to convert the string into the equivalent decimal valule). I know there is cast and typecast in matlab, but I couldnt get the good results with them.
THanks!!
回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 LabVIEW 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!