String value and sequently representation
이전 댓글 표시
Lets say i have string
M=['XASSANORXOOUOU']
and I want something like this
for i=1:7
Li=[M(i,i+1)]
so that it would give me like this result:
L1=XA
L2=SS
L3=AN
L4=OR
and so on....but this code
Li=[M(i,i+1)]
is not working. Could u help me please.
댓글 수: 3
John D'Errico
2014년 5월 27일
편집: John D'Errico
2014년 5월 27일
Please learn how to put your code in code blocks, as it was unreadable otherwise.
Akmyrat
2014년 5월 27일
채택된 답변
추가 답변 (1개)
M=['XASSANORXOOUOU'];
for i=1:length(M)/2
string=['L' num2str(i) '=M(2*(i-1)+1:2*i)']
eval(string)
end
카테고리
도움말 센터 및 File Exchange에서 Characters and Strings에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!