can i changed for loop index variable inside the loop in Matlab???
Posted
by shawana
on Stack Overflow
See other posts from Stack Overflow
or by shawana
Published on 2010-05-14T05:32:53Z
Indexed on
2010/05/14
5:44 UTC
Read the original article
Hit count: 187
hi every one. i need to change my loop variable inside the iterationa as ihave to acces array elements in the loop which is changing w.r.t size inside the loop. ashort piece of code is that:
que=[]; que=[2,3,4]; global len; len=size(que,2) x=4; for i=1:len if x<=10 que(x)= 5; len=size(que,2) x=x+1;
end
end que
array should print like: 2 3 4 5 5 5 5 5 5 5
but it is printed in such a way: 2 3 4 5 5 5.
how shuould it be accomplished in matlab? in visual c++ it happen correctly and print whole array of 10 elements which increases at run time plz reply me if have any ideaabout this as i m new into matlab
© Stack Overflow or respective owner