In Simulink Callback How to Automatically Display a Table of results, like what one can do with figure; plot()

10 次查看(过去 30 天)
I am trying to display the results of a simulink simulation model that reads and writes to simulated memory.
I have a function call to display these results, as a table, in the StopFcn callback in the model.
The callback will open figures and plot data automatically but I can't do the same with a table.
I would like the user/tester to be able to see the results pop up in table form (such as with figure;plot()) and not have to go search for a table in the workspace.
Example, How to pop up this table automatically

回答(1 个)

Ninad
Ninad 2023-9-15
Hi Kathy,
To display the results of a Simulink simulation as a table in a pop-up window, you can use the `uitable` function in MATLAB.
I have created a dummy Simulink Model using a `sine wave` block along with a `Scope` block.
Add the following function in a MATLAB (.m) file:
function myStopFcnCallback(simout)
% Extract the simulation results
data = simout.tout;
% Create a new figure
figure;
% Create a uitable to display the results
uitable('Data', data, 'Position', [20 20 400 300]);
end
In the Simulink Model, call the function defined above through the Stop Function Callback. To do so, go to:
Model Settings (dropdown) > Model Properties > StopFcn*
Write this in the `Simulation stop function` text box to the right side:
myStopFcnCallback(out);
I have attached the `demoTable.slx` model along with the `myStopFcnCallback.m` script file for your reference.
Reference:

类别

Help CenterFile Exchange 中查找有关 Programmatic Model Editing 的更多信息

标签

产品


版本

R2020b

Community Treasure Hunt

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

Start Hunting!

Translated by