In a For Iterator Subsystem, how to use the iteration variable ?

6 ビュー (過去 30 日間)
remi
remi 2013 年 4 月 22 日
Here is my problem : I set a 1-by-N array (A) in Matlab, then I run a simulation where I use a For Iterator Subsystem (i=iteration variable). This subsystem runs N times and I'd like to use i to call A(i) in other blocks (gain, constant, lk-tables, etc...)
I can't find a way to do this since the To Workspace Block doesn't make data available until the simulation is stopped or paused.
In other words, how can I use my iteration variable in real time and call A(i) in blocks during the simulation?
Thanks a lot in advance
  2 件のコメント
Kaustubha Govind
Kaustubha Govind 2013 年 4 月 22 日
編集済み: Kaustubha Govind 2013 年 4 月 22 日
Are these other blocks also inside the For Iterator subsystem? If not, is there a reason they aren't? Because once they're inside the For Iterator subsystem, they are effectively getting A(i) as input.
remi
remi 2013 年 4 月 23 日
編集済み: remi 2013 年 4 月 23 日
Yes they are, but my problem was too simplified. I actually need an access to cells, and A{i} isn't taken as input by my blocks but as inner parameter. Have a look on my answer to Guy Rouleau, I think my explanation is clearer. Thank you for your answer

サインインしてコメントする。

回答 (1 件)

Guy Rouleau
Guy Rouleau 2013 年 4 月 22 日
The iteration variable is a signal coming out of the For Iterator block.
Inside the subsystem, you can use a Selector block:
or Assignment block:
to read or write to elements of a vector or matrix A(i).
  1 件のコメント
remi
remi 2013 年 4 月 23 日
Thanks for your answer, but I may have simplified my problem in a wrong way. I'll be more accurate. Actually, depending on simulation parameters, I use an array of structures which can have one, two or X cells. Let's call this array "arrStructure". X is set with Matlab before the simulation is run and doesn't change until the next simulation parameters are choosen. For instance : arrStructure{1:3} is \<1x3 cell>, and each cell is \<1x1 struct>
In the for Iterator Subsystem, I want to access data contained in arrStructure{ i } for i=1:X. For instance, I need arrStructure{i}.value in a Gain Block, or arrStructure{i}.vector and arrStructure{i}.matrix in a Look-Up Table...
I can use neither Selector block nor Assignment block in this case, am I right ?
Thanks in advance

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeSubsystems についてさらに検索

製品

Community Treasure Hunt

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

Start Hunting!

Translated by