Clear Filters
Clear Filters

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

10 views (last 30 days)
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

Answers (1)

Ninad
Ninad on 15 Sep 2023
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:

Categories

Find more on Programmatic Model Editing in Help Center and File Exchange

Products


Release

R2020b

Community Treasure Hunt

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

Start Hunting!