String value and sequently representation
Mostra commenti meno recenti
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 Commenti
John D'Errico
il 27 Mag 2014
Modificato: John D'Errico
il 27 Mag 2014
Please learn how to put your code in code blocks, as it was unreadable otherwise.
Akmyrat
il 27 Mag 2014
Risposta accettata
Più risposte (1)
M=['XASSANORXOOUOU'];
for i=1:length(M)/2
string=['L' num2str(i) '=M(2*(i-1)+1:2*i)']
eval(string)
end
Categorie
Scopri di più su Characters and Strings in Centro assistenza e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!