Reading the data from another m file in a loop
Show older comments
Hi guys, I created two functions, in the second one I'd like to read the data from the first one like this but in a smarter way, is it possible to use a loop somehow here? I'd like to read from t1 till t4 and from y1 till y50 and it's not convinient to write every single variable.
t1=model.t1;
t2=model.t2;
t3=model.t3;
t4=model.t4;
y1=model.y1;
y2=model.y2;
y3=model.y3;
y4=model.y4;
y5=model.y5;
y6=model.y6;
y7=model.y7;
y8=model.y8;
y9=model.y9;
y10=model.y10;
1 Comment
dpb
on 6 May 2022
Use arrays and/or named fields instead -- don't create a sequence of variable names like this to begin with.
Accepted Answer
More Answers (0)
Categories
Find more on Loops and Conditional Statements in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!