simulink: assign values to a resistance by using matlab scripts

Dear all
There is a block in my circuit called R1 and its value needs to change everytime when I run the simulation. I would like to write an matlab script that does this automatically. I would like to store all the values of R1 in an arrey and everytime when I run my simulink simulation, one value of R1 is assigned to the corresponding block in my circuit. Does anyone know how this can be achieved?

回答(1 个)

Correctly to the comment above, the command to make this is SET_PARAM and certainly it is always in the documentation.
However, many users find it difficult to find the exact parameter they need to change. Two tips here.
get_param(gcb, 'ObjectParameters');
This return all existing parameters. Try
set_param(gcb, 'Name', 'Myblockname');
to familiarize with the syntax. Andreas there is also a list of all parameters here in the manual.

1 个评论

Alternatively, use "get(gcbh)" to list all the parameters with their values in command window.
The resistor block R1 mentioned by AAAA is from some specific toolbox (may be from SimElectronics) and it is not included in above list.

请先登录,再进行评论。

类别

帮助中心File Exchange 中查找有关 Simulink 的更多信息

提问:

2012-5-6

Community Treasure Hunt

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

Start Hunting!

Translated by