How do I pass Simulink variables from the “Configuration Parameters” to a GUI created using GUIDE?
3 次查看(过去 30 天)
显示 更早的评论
I have a GUI created in GUIDE that: 1. Selects a test data CSV file to be simulated from my directory and 2. Allows the user to press “Start” to begin Simulink simulation. The GUI is communicating with Simulink. The Simulink model has a Stateflow model included that is used for trouble shooting control logic. The GUI is implemented to allow someone not familiar with the design of the Simulink/Stateflow model to be able to trouble shoot any test data CSV file easily.
The problem I am having errors with is when pressing the pushbutton “start” in the GUI.fig that is associated with starting the Simulink model. In my GUI.m file for the “start” pushbutton function, I have “sim SimulinkModel” and than also call some plots that compare test data with simulated data. The errors come from the plots, where variables cannot be found, “??? Undefined function or variable 'sim_time'. “.
These variables are defined in the Simulink “Configuration Parameters”, accessed by pressing Ctrl+E while viewing the Simulink model. I am saving, “Save to Workplace”, these variables, i.e. “Time”, “Output”. How do I pass these variables from the Simulink model to the GUI so when I execute the GUI pushbutton “start” I can get the simulation to work? Note, the Simulink simulation works without any error when pressing “Start simulation” from Simulink.
I believe this is something that needs to be added to the GUI.m file for the pushbutton function.
Thank you for the help.
0 个评论
采纳的回答
Kaustubha Govind
2012-11-28
I think the problem might that you are defining the variables (sim_time, etc.) in the function workspace of your GUI, but the Simulink model is looking for them in the base workspace.
To ask Simulink to look in the function workspace, try:
options = simset('SrcWorkspace','current', 'DstWorkspace', 'current');
sim('SimulinkModel', options);
2 个评论
更多回答(1 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Model, Block, and Port Callbacks 的更多信息
产品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!