Get and set Simulink model data from Matlab?

1 view (last 30 days)
I have a simple model with 1 input and output. The input it directly linked to the output. I was wondering if there was any way I could get the input name, set a value to it, run it and see if the output matches the input. I want to try and do this from an .M file if possible. Thanks!

Accepted Answer

K E
K E on 17 May 2012
Perhaps this explanation of the get_param and set_param commands will help. You could use get_param and set_param from within a mfile that uses the sim command to run the simulation. If your input and output are scalars, just take their difference in the mfile after the sim command. If they are time series,
isDifferent = sum(myInput - myOutput) ~= 0 ;
  3 Comments
K E
K E on 17 May 2012
If you are doing this from inside a Matlab script, you could use the disp command (http://www.mathworks.com/help/techdoc/ref/disp.html) to display the value returned by get_param at the Matlab prompt. Or you could make a GUI to show it but I don't know the details.
Kaustubha Govind
Kaustubha Govind on 18 May 2012
Lucas: You can use the Inport/Outport blocks to import/export data using the "Data Import/Export" pane of the model's Configuraion Parameters window. See here for more explanation: http://www.mathworks.com/help/toolbox/simulink/ug/bsuwmmp.html

Sign in to comment.

More Answers (0)

Categories

Find more on Programmatic Model Editing in Help Center and File Exchange

Tags

Products

Community Treasure Hunt

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

Start Hunting!