Retrieve Simulink model input dimensions using matlab

I am trying to use matlab to find an input signal block and get its allowed dimension. i am using the get_param function and thought using the compileddimension method would work, but the issue is that the input block at that state is just an input block, there are no associated dimensions of that block yet because the variable has not been created in the matlab workspace yet, but the model knows the allowed dimensions because it back propagates them from its downstream connections and i can see it in the line path of the model, yet the compileddimension method is blank. Can anyone help me on how to pull the allowed dimensions for a signal?

 採用された回答

Fangjun Jiang
Fangjun Jiang 2022 年 10 月 19 日

0 投票

I think Simulink has a series of ways to determine the signal dimensions. Propagation takes higher priority than back propagation, or the priority is determined by settings in the block.
In your snapshot, the model has errors because workspace data has not been located yet. The model won't pass "model update" thus the compileddimension is invalid.
To get compileddimension, the model has to pass "model update".
To pass "model update", the data for the "From Workspace" blocks has to be located.

5 件のコメント

Eduardo Garcia
Eduardo Garcia 2022 年 10 月 19 日
Thank you for the response. I can understand that propagation takes higher priority than the back propagation, but wondering if there is any other method or way to get the back propagated dimension. I know the snapshot shows an error, as i mentioned, at the time that i need to pull the dimension, the from workspace variable has not been created yet.
Fangjun Jiang
Fangjun Jiang 2022 年 10 月 19 日
編集済み: Fangjun Jiang 2022 年 10 月 19 日
Each block has its own setting. Most block allows propagation, back propagation, or inherient, or to be explicitly specified. "From Workspace" is a source block. It doesn't have such an option. It has to be inherited from the data source.
If you are looking for the dimension infomation of a particular block along a pathway, maybe the best way is to specify that in the block. In certain situation, it is best to specify that in the block. It will be used as an "anchor" to make sure upstream or downstream dimension is correct.
In your snapshot, the "model update" is partially done but then stopped due to the error. The most info it can get for the dimension of the subsystem Inport block is from the back propagation. I guess the information is availble since it is displayed. But you were saying running get_param('block','compileddimension') returns blank after "model update". It sounds like you could use that info, even though you know that info is from back propagation and it could be wrong.
I suggest you making a simple example and sending to the Mathworks tech support to see if they can help you.
Eduardo Garcia
Eduardo Garcia 2022 年 10 月 19 日
Thanks again for your response. I will contact Mathworks tech support.
Paul
Paul 2024 年 1 月 18 日
Hi Eduardo,
You may be interested in this thread and/or this thread (particularly the Answer from @Andy Bartlett)
Eduardo Garcia
Eduardo Garcia 2024 年 1 月 19 日
Thank you. I figured this out. Learning as i go.

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

その他の回答 (0 件)

製品

リリース

R2020a

Community Treasure Hunt

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

Start Hunting!

Translated by