Running simultaneously a GUI file and Simulink model with S-function

Hi, I have 3 files: (1) Simulink model (2)S-function level 1 matlab code (3)M-file GUI with object drawing.The simulink model feeds a sine wave into an S function block. I want is to get the output of the S-function into a variable in the GUI file. When I run the GUI file which was designed with the help of guide, the simulink model start running using the command Sim() until the simulation time finish then the object drawing start to appear. What I want is that they run simultaneously because I want to control the movement of the object with the output of the S-function. Please advice me on this issue. See my S- function output function:
Function [sys,x0,str,ts]=mdlOutputs (t,x,u) fig=myGUI hnaldes=guidata(fig) n=u(2) handles.myGUI.angle=n sys=[]

 Accepted Answer

You could try adding drawnow() commands after you update the graphics.

6 Comments

Thanks for your answer, I am not sure what you mean exactly. Maybe my question was not clear. What I meant is that my Simulink model set to infinity simulation time. When the sim() command is executed from the GUI M-file the Simulink model and its S-function start. However, the drawings codes which are below the sim() command in the same file never executed.Thanks
You put a breakpoint in to verify that those commands are not reached? Or you are relying on the timing what shows up on the screen? graphics commands are not reflected on the screen until a drawnow() or pause() or figure() or until the program returns to the command line.
Next step would be to put in a breakpoint to see if the graphics commands are called promptly or not.
Please see my comments on the other question
http://www.mathworks.co.uk/matlabcentral/answers/26865-please-urgent-help
If the two are the same Question, they should be merged together and one deleted. If they are not the same Question, then mixing the topics between the two is not a good idea.
http://www.mathworks.com/help/techdoc/ref/f16-11063.html#bsc5ynx
http://www.mathworks.com/help/techdoc/matlab_prog/f10-60570.html#f10-60679

Sign in to comment.

More Answers (0)

Categories

Find more on Simulation in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!