Read data from TCP/IP from labview
12 ビュー (過去 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!!
1 件のコメント
回答 (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!