필터 지우기
필터 지우기

call variables in workspace in loop

조회 수: 5 (최근 30일)
giulio zamboni
giulio zamboni 2019년 4월 26일
댓글: Rik 2019년 4월 26일
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
Matt J
Matt J 2019년 4월 26일
Why can't you create an array in Simulink and then send the array with all the results to the Matlab workspace?
Rik
Rik 2019년 4월 26일
'Answer' by giulio zamboni moved here:
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?

댓글을 달려면 로그인하십시오.

답변 (0개)

카테고리

Help CenterFile Exchange에서 Programmatic Model Editing에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by