matlab - Assign a Name to each Iteration -


in matlab, i'm trying assign name each iteration in loop. let's take fundamental loop:

for = 1:3 x = i^2 end 

and the output is:

x = 1; x = 4; x = 9; 

what want assign x's x(1), x(2), , x(3). i'm trying achieve have loop output as:

x(1) = 1; x(2) = 4; x(3) = 9; 

in loop showed, scalar value x gets updated on every iteration. can instead store values of iteration in vector.

for instance:

for = 1:3   x(i) = i^2; end 

x vector , x(i) holds ith iteration.


Comments

Popular posts from this blog

linux - xterm copying to CLIPBOARD using copy-selection causes automatic updating of CLIPBOARD upon mouse selection -

c++ - qgraphicsview horizontal scrolling always has a vertical delta -