How I can define a varying parameter in Simulink Test?

57 ビュー (過去 30 日間)
Ayyoub
Ayyoub 2016 年 2 月 14 日
コメント済み: Sarah Dagen 2024 年 2 月 13 日
Hi,
I am designing a Test Harness for my model. I have a parameter in the simulink model(a gain) and I want to develop a test sequence to test the sensitivity of my model with respect to this parameter. simply, I want to design a DOE for my model. I defined the parameter in the test sequence and I define that in the Model Explorer, too. But, I received the below error. Could you please guide me that how I can define a parameter that I can change in each test by Test Sequence Editor block?
Thanks for your consideration and time.
regards, --------- "Constant or Parameter data 'AAA' on left hand side of an expression.
State 'step_2' "AAA" ----------
  1 件のコメント
Ayyoub
Ayyoub 2016 年 2 月 25 日
編集済み: Ayyoub 2016 年 2 月 25 日
Thanks for your answer Akshata. I tried your solution, but "symbol wizard" window is opened and ask to give a role(input, constant, parameter,...) to the name of gain block. And, all of these options cause another error.

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

採用された回答

Sarah Dagen
Sarah Dagen 2019 年 6 月 10 日
To change this gain value from a test sequence block, you need to follow a pattern such as in the image below:
param_in_test_sequence.png
You need to declare evalin, set_param, and num2str as coder.extrinsic in the initialization step of the test sequence. You can then use these commands in sequence steps to change the gain value in the base workspace during simulation.
  3 件のコメント
Pratik
Pratik 2024 年 2 月 13 日
Hi, if varibels are already in model workspace then is it possible to vary in test sequncve block?
Sarah Dagen
Sarah Dagen 2024 年 2 月 13 日
If you promote your model workspace parameter to be a model argument, you can then use the Parameter Writer block to change its value. The approach has the advantage of simpler code in the Test Sequence block (no coder.extrinsic, set_param, etc.). You simply add an additional output from the Test Sequence block and use that to drive the Parameter Writer.

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

その他の回答 (1 件)

Chandrasekhar
Chandrasekhar 2016 年 2 月 15 日
i guess you want to change the gain value while the simulink model is running. you can do that by giving the below command in your test sequence
set_param(<gain block name>,'Gain',<value>)
  3 件のコメント
Chandrasekhar
Chandrasekhar 2016 年 3 月 2 日
Could you please let me know the context how you want to change the gain value.
Ayyoub
Ayyoub 2016 年 3 月 4 日
編集済み: Ayyoub 2016 年 3 月 4 日
There is a gain in my Simulink Model, and I want to change it after each transition in Test Sequence block. For instance: (A is the gain in my Simulink Model)
step 1 after(2,sec) step 2 .... A=1; %(value of gain in step 1)
Step 2 after(4,sec) step 3 .... A=5 %(value of gain in step 2)
....

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

カテゴリ

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

Community Treasure Hunt

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

Start Hunting!

Translated by