带读取文本

文件名:16_ASII
b1 bb fe
b1 a0 1f
30 f3 7b
30 7f c7
9f ff cf
b0 3f ff
b0 f1 ff
31 9f cf
30 f8 36
30 c3 4f
20 f8 7f
b0 ff fd
30 7e cf
b0 7f e7
30 30 df
30 e7 fe
b1 ff 7f
b0 e0 3f
b0 1d be
b0 ce fd

读取代码

clear all;
clc;
src = textread('16_ASII','%s');%将TXT中的数据以文本的方式取回
idx = 1;
for i=1:3:length(src)
    [src{i:i+2}]
    [src{i+2:i+2} src{i+1:i+1} src{i:i}]
    dest1(idx) = hex2dec([src{i:i+2}]);
    dest(idx) = hex2dec([src{i+2:i+2} src{i+1:i+1} src{i:i}]);
    idx = idx + 1;
end
x=1:length(dest);
plot(x,dest,'r', x, dest1, 'b');