很简单,我不会
clear
a=input('Input str:','s');
a
n=length(a)
abcnum=0;
spcnum=0;
numnum=0;
othnum=0;
for i=1:n
if ((a(i)>='a')&&(a(i)<='z'))...
||((a(i)>='A')&&(a(i)<='Z'))
abcnum=abcnum+1;
elseif ((a(i)>='0')&&(a(i)<='9'))
numnum=numnum+1;
elseif (a(i)==' ')
spcnum=spcnum+1;
else
othnum=othnum+1;
end
end
abcnum
numnum
spcnum
othnum