For loop with running parameter out of struct

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

Antworten (2)

madhan ravi
madhan ravi am 24 Okt. 2018
Bearbeitet: madhan ravi am 24 Okt. 2018

0 Stimmen

for i=1:100
Test.x(i)=i ; %an example
Test.y(i)=x.^(i) ;
end
save('mymat.mat',Test)
KSSV
KSSV am 24 Okt. 2018

0 Stimmen

mystruct = struct ;
for i = 1:10
mystruct(i).value = rand ;
end

Kategorien

Mehr zu Loops and Conditional Statements finden Sie in Hilfe-Center und File Exchange

Tags

Gefragt:

am 24 Okt. 2018

Bearbeitet:

am 24 Okt. 2018

Community Treasure Hunt

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

Start Hunting!

Translated by