How to edit the internal properties of any simulink block using only matlab code?
5 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Joseph Jennings
am 19 Okt. 2015
Kommentiert: Joseph Jennings
am 19 Okt. 2015
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.
0 Kommentare
Akzeptierte Antwort
goerk
am 19 Okt. 2015
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.
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Simulink Functions finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!