- Prepare Your Simulink Model:First, make sure your Simulink model is set up to provide progress updates. This could involve adding a custom block or using a MATLAB Function block to send updates to the MATLAB workspace or trigger an event listener.
- Create a Listener for parsim:When you execute parsim, the SimulationOutput object it returns can have listeners attached to it. These listeners will be responsible for updating your progress bar.
- Refresh the GUI:The listener should execute a function (such as updategui.m) to update your progress bar in the app.
Real-Time Interface between App in AppDesigner and Simulink using parsim
4 次查看(过去 30 天)
显示 更早的评论
I would like to optimize my progress bar in my Matlab app, which I am building in AppDesigner. I am currently using the app to start my Simulink model with parsim and simulate several simulation runs. However, I do not get any feedback on the progress of the individual simulations. I got the Listener option as a tip. I have implemented this. The specially created updategui.m file works. My question is, how can I combine parsim and the call of the updategui.m file? As soon as the parsim command is executed, I can no longer execute anything else. However, according to the instructions, I have to execute the updategui.m file as soon as the simulation is running. Otherwise exec_event_listener does not work.
Thank you.
0 个评论
采纳的回答
prabhat kumar sharma
2025-1-23
Hello Fabian,
To enhance your progress bar in a MATLAB App Designer application while using parsim for running parallel simulations, you can utilize listeners to track the simulation progress. The main idea is to attach a listener to the SimulationOutput object generated by parsim, and use this to refresh your GUI's progress bar.Steps to Implement a Progress Bar with parsim:
% Inside your App Designer app, set up the parsim and listener
function runSimulations(app)
% Configure your Simulink model for parallel simulation
in = Simulink.SimulationInput('your_model_name');
% Adjust the input if necessary (e.g., set parameters)
% Set up the listener for progress updates
listener = @(src, event) updateProgress(app, event);
% Run parsim with the listener
parsimOptions = 'ShowProgress', 'on', 'TransferBaseWorkspaceVariables', 'on';
simOut = parsim(in, ...
'ShowProgress', 'on', ...
'TransferBaseWorkspaceVariables', 'on', ...
'SetupFcn', @(x) addlistener(x, 'SimulationOutput', 'PostSimFcn', listener));
end
% Function to update progress in the GUI
function updateProgress(app, event)
% Extract progress information from event
progress = event.Progress;
% Update your progress bar in the app
app.ProgressBar.Value = progress; % Assuming you have a ProgressBar component
end
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Configure and View Diagnostics 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!