Borrar filtros
Borrar filtros

For loop with running parameter out of struct

1 visualización (últimos 30 días)
Lucas Maiß
Lucas Maiß el 24 de Oct. de 2018
Editada: madhan ravi el 24 de Oct. de 2018
Hello, I would like to run a for loop like this:
for Test.i=1:100 do something end
My intention is to have one struct where all my variables from my quite small script are stored and I don't mess up the workspace of the whole model.
Thanks in advance

Respuestas (2)

madhan ravi
madhan ravi el 24 de Oct. de 2018
Editada: madhan ravi el 24 de Oct. de 2018
for i=1:100
Test.x(i)=i ; %an example
Test.y(i)=x.^(i) ;
end
save('mymat.mat',Test)

KSSV
KSSV el 24 de Oct. de 2018
mystruct = struct ;
for i = 1:10
mystruct(i).value = rand ;
end

Categorías

Más información sobre Loops and Conditional Statements en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by