synchronizing simulink with m-file
Mostrar comentarios más antiguos
im need to synchronize output from simulink with MATLAB platform
currrently what im using is (running in matlab platform)
rto = get_param(gcb,'RuntimeObject');
blockData = rto.OutputPort(1).Data ;
but it only gives me one data and it requires me to run it manaully. Need it to run in MATLAB platform automatically and in sync with the Simulink model.
Advise/Direction needed thanks.
Respuesta aceptada
Más respuestas (1)
Tan Edwin
el 18 de Abr. de 2011
6 comentarios
Tan Edwin
el 18 de Abr. de 2011
Jarrod Rivituso
el 18 de Abr. de 2011
When taking the callback approach, you should write a MATLAB function to serve as the callback. You write this outside of an S-function. The callback must have certain inputs, as shown in the doc example:
function callbackFcn(block, eventData)
blockData = block.OutputPort(1).Data ;
So, you don't need to get the runtime object again, and the callback function will be called at each simulation step.
Tan Edwin
el 19 de Abr. de 2011
Jarrod Rivituso
el 19 de Abr. de 2011
Do you really want a .mat file for each time step? That seems excessive - there could easily be thousands of time steps in a single simulation.
The rules for the callback function are the same with any function. Each function is given its own workspace, which is separate from the base workspace.
What exactly are you trying to accomplish here? I have a hunch there may be other ways you could do this besides outputting a .mat file for each time step.
For instance, you can use signal logging to log simulation data throughout an entire simulation very easily:
http://www.mathworks.com/access/helpdesk/help/toolbox/simulink/ug/brh7636.html
Tan Edwin
el 20 de Abr. de 2011
Jarrod Rivituso
el 20 de Abr. de 2011
Ooops, looks like it changed. Here ya go
http://www.mathworks.com/help/toolbox/simulink/ug/f11-47048.html
Categorías
Más información sobre Event Functions en Centro de ayuda y File Exchange.
Productos
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!