readlab.m
来自「能够简单识别0~9十个数字的matlab程序」· M 代码 · 共 64 行
M
64 行
function [qs,zz,num]=readlab(file)
fid=fopen(file,'r','b');
if fid < 0
error(sprintf('Cannot read from file %s',file));
end
F= fread(fid,'uchar');
j=1;
for i=1:4
b=0;
while F(j) ~= 32
aa=F(j);
j=j+1;
aa=aa-48;
b=b*10+aa;
end
j=j+1;
qs(i)=b;
b=0;
while F(j) ~= 32
aa=F(j);
j=j+1;
aa=aa-48;
b=b*10+aa;
end
j=j+1;
zz(i)=b;
b=0;
while F(j) ~= 10
aa=F(j);
j=j+1;
b=b+aa;
end
num(i)=b;
j=j+1;
end
for i=1:4
switch num(i)
case {236}
num(i)=5;
case {422}
num(i)=7;
case {195}
num(i)=8;
case {330}
num(i)=6;
case {523}
num(i)=2;
case {322}
num(i)=3;
case {220}
num(i)=4;
case {331}
num(i)=9;
case {424}
num(i)=0;
case {329}
num(i)=1;
otherwise
num(i)=num(i);
end
end
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?