- 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!