Mostra commenti meno recenti
Hi, I have declared the size of array as 4*4.When i run the third for loop the size of array becomes 49*49.Dont know why this happens in that loop?
pat1='11';
arr=zeros(4,4);
len=length(pat1);
for i=1:4
for j=1:4
arr(i,j)=l+2;
end
end
for j=1:4
arr(1,j)=1;
end
for i=1:len-1
arr(pat1(i),pat1(i+1))=l-i;
end
for i=1:4
arr(i,1)=l+1;
end
[EDITED, Jan Simon, Code formatted]
1 Commento
Walter Roberson
il 5 Dic 2011
http://www.mathworks.com/matlabcentral/answers/13205-tutorial-how-to-format-your-question-with-markup
Risposta accettata
Più risposte (1)
Walter Roberson
il 5 Dic 2011
0 voti
49 is the numeric equivalent of the character '1' . You are trying to index your array "arr" at the character pat1(i)
Categorie
Scopri di più su Matrices and Arrays 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!