call variables in workspace in loop
2 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Hallo, I have a simulink model that, after simulation, stores in the workspace a certain number of variables (array) (the number can be different from time to time).
These variables are called: pipe1, pipe2, pipe3, etc
After the simulation I need to run a script .m in which I compute, for each variable, the maximum value.
I have to do it dinamically, my script should view how many pipe variables are in the workspace and the for each of them compute the maximum value.
I don't know how to do that! With "who" function I am able to find all variables NAMES containing "pipe" but from these names I don't really know how to build a for cycle in which I call each variable to do my calculation.
p.s. I would be very happy not to have this issue, but in my model I have many To Workspace blocks and it doesn't allow me to give them always the same name! If that was possible I wolud have called at the stopfcn of each block the .m script using always the same variable (array) with which get the max value (overwriting it at each block). So that I struggled to manage to give (automatically) differnet names to my To Workspace blocks. Now that I achive this goal, I don't know how to call my variables in my .m script!!
Thank you so much
2 Kommentare
Matt J
am 26 Apr. 2019
Why can't you create an array in Simulink and then send the array with all the results to the Matlab workspace?
Rik
am 26 Apr. 2019
Hi, Could you please give me an examples as hint? I'm sorry, I'm a beginner. In my model called PLANT I have many submodels called PIPE (all of them derived from the original submodel in my custum library). In this submodels, for each one, I need to get the max of the simulation values and then wrote the results, with other output, to an .xls file, passing through matlab script.
Reading your answer I suppose I should build a matrix in which each coloumn is a vector output from each pipe submodel. Is it right? How should I don't that?
Antworten (0)
Siehe auch
Kategorien
Mehr zu Naming Conventions finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!