Systematically pause Simulink model and continue from Matlab command line
18 ビュー (過去 30 日間)
古いコメントを表示
Is it possible to have Matlab start a Simulink model (fixed step, discrete) and after each sample step, the model pauses, allows Matlab to do some data handling from the model, then waits for Matlab to tell the model to resume the next sample step? I have a very specific application that requires some functions in Matlab but I want to use Simulink to handle most of the heavy lifting.
0 件のコメント
採用された回答
Kaustubha Govind
2013 年 7 月 2 日
What kind of data handling would you like to do in MATLAB? You might want to look at Access Block Data During Simulation, which lets you work your MATLAB code into the simulation process instead of artificially pausing/continuing.
3 件のコメント
Kaustubha Govind
2013 年 7 月 3 日
Thomas: The interface in the link I posted doesn't provide arbitrary access, but is indeed step-by-step - if you read the documentation, you will see that the mechanism involves attaching a PostOutputs callback to a specific block, so your function is called at every step that the block produces new outputs. It doesn't matter how long your code takes to execute - Simulink should wait until it's done.
その他の回答 (3 件)
Guru
2013 年 7 月 3 日
Honestly, this is easier to do if you use MATLAB blocks within your Simulink to validate the results that you are looking for. However you can either use the Simulink Debugger commands from MATLAB to step through each individual block output based on sorted order, or you use:
set_param('model_name','SimulationCommand','pause') set_param('model_name','SimulationCommand','start') set_param('model_name','SimulationCommand','stop')
which are the command line functions that are equivalent to clicking the pause, play, stop buttons respectively.
0 件のコメント
Guy Rouleau
2013 年 7 月 2 日
In most cases where I have seen users asking to control the execution of a model from MATLAB code, the most appropriate solution was to include the MATLAB code inside the simulation and let simulink control the execution.
Whatever data you wan to extract from the model at every step should be available on a signal line. So you it should be possible to feed it to a block that you can code with MATLAB code (MATLAB Function block, MATLAB s-function, interpreted MATLAB Function block, etc.) The block will do your processing and it will be available as a signal to other blocks for the next step.
4 件のコメント
Daniel Rutherford
2020 年 3 月 11 日
編集済み: Daniel Rutherford
2020 年 3 月 11 日
So, if I have a legacy matlab simulation (lets say a seeker), and Bubba wants me to use state dynamics from a 3-DOF Simulink Simulation to provide kinematic information periodically for each seeker update dwell, I should trash my legacy, 2000 hour test matlab simulation, and throw it into the disfunctionality of simulink? I'd rather rewrite the 3DOF in a matlab script.
There needs to be a better effort by matlab to integrate simulink results into a matlab script.
Preferably, I'd like to use a simulink model like I use the call to an ode function.
参考
カテゴリ
Help Center および File Exchange で Simulink Functions についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!