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!!
댓글 수: 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!