필터 지우기
필터 지우기

How to edit the internal properties of any simulink block using only matlab code?

조회 수: 9 (최근 30일)
I have been searching for weeks now using google, mathworks and youtube in an effort to find out if there is a way to edit the properties of a simulink block for example, the step function block has 4 properties when you double click it that open in a dialog box. 1) Step time, 2) intial value 3) final value and the fourth one i forget as im not in class at this moment I am home and trying to get an answer on this to help me write a complete script that will generate the blocks, add the lines, adjust the properties of the blocks, set the parameters of the simulation and then run the simulation.
I have already seen a number of tutorials on this site that show how to generate the blocks, add the lines and adjust the simulation parameters. However I've never found anything can show me how to manipulate each blocks properties strictly using matlab code.
So far I have written quite extensive m files that will read data in from excel generate array's find specified data ranges within the arrays, perform all the calculations however, when i get to the part where i need to build the simulink model, the only thing i can do is build the model and add lines the rest has to be done manually.
The reason I would like to do this is because our class has taken one gigantic lab experiment and broken it up into 10 smaller experiments where each one builds on the other. So my thought is this, if i can build an m file that does everything for me then each week is only a few lines of tweaking the code rather than several hours of typing the same things that have already been typed the weeks before.
If some one could possibly teach me how to do this I would be eternally grateful. Also if it is as simple as using the set param code please provide an example with a block that works so that way I can try to apply it. I've tried reading all the help documentation on the set param and still cant figure it out. Thank you in advance to anyone who takes the time to read this.

채택된 답변

goerk
goerk 2015년 10월 19일
I think this is what you'r looking for:
block = add_block('built-in/Step', 'Test2015a/myStep','Position',[ 450 375 500 425])
% get_param(block,'ObjectParameters') % get all parameters and look for the names
set_param(block,'Time',0.5);
set_param(block,'Before',1);
set_param(block,'After',1);
set_param(block,'SampleTime',-1);
sometimes it is not that easy to find the right parameter names.
  댓글 수: 1
Joseph Jennings
Joseph Jennings 2015년 10월 19일
If this works i'll definitely be upvoting this as best answer thank you so much for your time and I figured it was the set param operation but i couldnt get it work properly, your code looks beautiful thank you very much. I will let you know if this works for me after class on tuesday! thanks again!

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Simulink Functions에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by