why the error in the following " set_param(​BlockName,​BlockParam​eter,Strin​gValue); "

I am trying to change the parameters inside a Linear Transfomer Magnetization resistance and inductance [Rm(pu) Lm(pu)]:. These parameters are named as RmLm when I view the mask. I am using Embedded MATLAB function block to set the parameters using set_param. The full code for MATLAB function block as following:
function ChangeParam(u) %#codegen
coder.extrinsic('set_param');
coder.extrinsic('num2str');
BlockName = 'Transfomer_Dynamic/Linear Transformer';
BlockParameter = 'RmLm';
StringValue = [num2str(u) ' ' num2str(u)];
set_param(BlockName,BlockParameter,StringValue);
I am getting the following error and I tried to find the debug but I am not be able. could anyone help or recommend me any suggestions ?
Cannot change parameter 'Magnetization resistance and inductance [Rm(pu) Lm(pu)]: (RmLm)' of 'Transfomer_Dynamic/Linear Transformer'
while simulation is running Error in 'Transfomer_Dynamic/MATLAB Function' (line 10) set_param(BlockName,BlockParameter,StringValue);

回答 (1 件)

Walter Roberson
Walter Roberson 2023 年 5 月 10 日
編集済み: Walter Roberson 2023 年 5 月 10 日

0 投票

Only tuneable parameters can be changed while the simulation is running.
In some situations it is workable to run a MATLAB function that sets parameters, then invokes sim() with a stop time, then examines results, and loops back to try different parameters.

6 件のコメント

Willim
Willim 2023 年 5 月 10 日
How can I know if the parameters is tunable or not. If the parameters are not tunable , What is the way around it ? Also, could I use allowpcode in this case ?
Willim
Willim 2023 年 5 月 13 日
Is there any way to make the untunable parameters as tunable ? I am not trying to tune it to the right value. I want to investiagte the behaviour for the transfomer while the Magnetization inductance (Lm) is changing over the running time baecuse of the change in the load.
Walter Roberson
Walter Roberson 2023 年 5 月 13 日
I noticed that previous link is for Simulink Desktop Real-TIme, which has more restrictions than Simulink.
Willim
Willim 2023 年 5 月 14 日
編集済み: Walter Roberson 2023 年 5 月 14 日
>> paramInfo.RmLm
ans =
struct with fields:
Prompt: 'Magnetization resistance and inductance [Rm(pu) Lm(pu)]:'
Type: 'string'
Enum: {}
Attributes: {'read-write' 'read-only-if-compiled' 'link-instance'}
This emphsizs that Magnetization resistance and inductance [Rm(pu) Lm(pu)] is not tunable. It cannot be changed during simulation running.
My question now is what is the way around it to have a model with tunable Magnetization resistance and inductance [Rm(pu) Lm(pu)]. Is there any way ?. If not, what is your recommendation ?
Walter Roberson
Walter Roberson 2023 年 5 月 14 日
I do not know if there is a work-around. I think it would be worth experimenting with making the value a global variable as is discussed in the link, but I do not know if it will work.

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

カテゴリ

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

質問済み:

2023 年 5 月 10 日

コメント済み:

2023 年 5 月 14 日

Community Treasure Hunt

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

Start Hunting!

Translated by