简体   繁体   中英

Interfacing Simulink with MATLAB

Designing a model which is doing some comparison on data ,fetched from GUI. I have ".m file" which has GUI functionality based on GUI GUIDE.I want to run my .m file (Inside I simulate my model also once data has been read.) I am using one Push Button on GUI.After pushing that button my model starts simulating as per code mentioned below.

h=str2num(get(handles.edit_h,'String')); 
l=str2num(get(handles.edit_l,'String')); 
options = simset('SrcWorkspace','current');
sim('level_monitor',[],options);

My model gives output as constant values(like 1,2,3,4).I dont want to plot graph on scope but want to use this constant variables in GUI for setting string message on UI.How to access value coming to output port of simulink via GUI function(m-script).

As per my understanding MATLAB code uses its own workspace and Simulink has its own workspace.(Base and model workspace). How to read data available at Simulink outport to my matlab code(GUI .m file)? I have tried using "Simout(To Workspace block) also but it not resolve my issue. Kindly help me out with this.

You should be using the form of the sim function that returns an output structure, ie

simOut = sim('level_monitor',[],options);

simOut is then a structure that contains fields for all of the variables that the simulation would nominally write to the Base Workspace.

See

>> doc sim

for more information.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM