LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

using matlab script in labview

I'm using matlab script in labview to calcualte the crc16 valure of a Integer array,but something seems wrong .

 

The code test ok in matlab:

matlab crc16 calc.jpg

 

 the labview program test wrong:

labview crc16 calc.jpg

 

labview program.jpg

  Is there anything need to modify? thanks! 

 

the m-file is: 

crc_ccitt_matlab.m

function crc_val = crc_ccitt_matlab (message)
crc = uint16(0);

for i = 1:length(message)
crc = bitxor(crc,bitshift(message(i),8));

for j = 1:8
if (bitand(crc, hex2dec('8000')) > 0)
crc = bitxor(bitshift(crc, 1), hex2dec('1021'));
else
crc = bitshift(crc, 1);
end
end
end

crc_val = crc;
end

0 Kudos
Message 1 of 3
(2,881 Views)
before start to check cods as I know you have to install matlab software to use this scrip
did you install it ?
0 Kudos
Message 2 of 3
(2,868 Views)

yes,i have installed matlab r2010b , and in some other programs the matlab scripts can work.

0 Kudos
Message 3 of 3
(2,861 Views)