Get and set Simulink model data from Matlab?

1 次查看(过去 30 天)
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!

采纳的回答

K E
K E 2012-5-17
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 个评论
K E
K E 2012-5-17
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 2012-5-18
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

请先登录,再进行评论。

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Programmatic Model Editing 的更多信息

标签

产品

Community Treasure Hunt

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

Start Hunting!

Translated by