0

Hey guys, I dont know if I'm wording my problem right but I have created a GUI, an m-file and a simulink. Initially I had the variables going from the m-file into the Simulink, but now I want the user to be able to change the variables so I have created a GUI. I keep getting an error though, I dont think the variables are going from the GUI m-file to the simulink model anymore. I remember you had to set something to do it, like simset or setcurrentsim or something but I cannot remember, so I was wondering can anyone help me with this one?

4

2 回答 2

0

使用 set_param 命令。

它应该看起来像这样:

set_param('model name/block name','block type',string);

在我的代码中,我有一个名为 Pitch_Control 的模型,带有一个名为 Pitch Rate Sensor 的增益模块。k2 是一个整数。

set_param('Pitch_Control/Pitch Rate Sensor','Gain',num2str(k2));

我希望这有帮助。

于 2010-11-25T20:15:00.253 回答
0

set_param有效,但它是一种非常具体的方式,只能用于更改块设置而不是传递参数。

您正在寻找的是assignin。您可以使用:assignin('base','Parametername',value); 由于 Simulink 从基础工作区导入变量,它的作用与您的旧脚本相同。

于 2015-11-04T16:08:56.360 回答