M-file S-function dimension

Can I define the S-function input/output dimension using another input parameters of my Simulink block?
For eg: there are 3 input and 1 output, first input is the row of third input, and second input is the column of the third input, then in the M-code setup function, i type:
block.InputPort(2).Dimensions = [block.InputPort(1).data block.InputPort(3).data];
Is this be possible? I need to do this as when my global parameters (1st and 2nd input) change in simulink, my 3rd input size will change. Hope someone can help. Thanks.

回答 (1 件)

Kaustubha Govind
Kaustubha Govind 2011 年 8 月 16 日

0 投票

You shouldn't have to specify the input size of a variable-size signal - the S-function can get this information from the Simulink engine directly, as long as you can construct the input signals correctly and feed into port#2. In the setup() method, you can simply specify the input port dimensions mode as 'Variable':
block.InputPort(2).DimensionsMode = 'Variable';
FYI, you can also look at the documentation example for Level-2 MATLAB S-Function with Variable-Size Signals. Type the following at the MATLAB prompt to open up the demo model:
>> msfcndemo_varsize

2 件のコメント

Chong Huan
Chong Huan 2011 年 8 月 17 日
wow..You are indeed an expert =D I manage to solve the problem..Thanks Kaustubha =D
Kaustubha Govind
Kaustubha Govind 2011 年 8 月 17 日
Glad to be of help! :)

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

カテゴリ

ヘルプ センター および File ExchangeSimulink についてさらに検索

タグ

質問済み:

2011 年 8 月 16 日

Community Treasure Hunt

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

Start Hunting!

Translated by