dat_h= int16(123);
dat_l= int16(-321);
if dat_h >= 0
dat_h_bin = dec2bin(dat_h,16);
else
dat_h_bin = dec2bin(2^16-dat_h,16);
end
if dat_l >= 0
dat_l_bin = dec2bin(dat_l,16);
dat_l_bin = dec2bin(2^16-dat_l,16);
dout = single(bin2dec([dat_h_bin,dat_l_bin]));
dout = single(2^32 - bin2dec([dat_h_bin,dat_l_bin]));
dat_h= int16(123);
dat_l= int16(-321);
if dat_h >= 0
dat_h_bin = dec2bin(dat_h,16);
else
dat_h_bin = dec2bin(2^16-dat_h,16);
end
if dat_l >= 0
dat_l_bin = dec2bin(dat_l,16);
else
dat_l_bin = dec2bin(2^16-dat_l,16);
end
if dat_h >= 0
dout = single(bin2dec([dat_h_bin,dat_l_bin]));
else
dout = single(2^32 - bin2dec([dat_h_bin,dat_l_bin]));
end