发布网友 发布时间:2024-10-21 05:20
共1个回答
热心网友 时间:2024-11-03 00:29
用str2num.追答str='HILLCRYP';
N=size(str);
j=1;
for i=1:N(2)
switch str(i)
case 'H'
strNew(j)='5';
j=j+1;
case 'I'
strNew(j)='2';
j=j+1;
strNew(j)='3';
j=j+1;
case 'L'
strNew(j)='1';
j=j+1;
case 'C'
strNew(j)='4';
j=j+1;
case 'R'
strNew(j)='6';
j=j+1;
case 'Y'
strNew(j)='7';
j=j+1;
case 'P'
strNew(j)='8';
j=j+1;
otherwise
end
end
strNew
array=str2num(strNew)
结果:
strNew =
523114678
array =
523114678