Clear Filters
Clear Filters

Info

This question is closed. Reopen it to edit or answer.

How can I do side-by-side simulation of Simulink files by using for-loop in MATLAB GUI or is there another way to do it?

1 view (last 30 days)
Hello people,
I want to ask how I make the following code functioning for side-by-side simulation of Simulink files, which are saved in 'PATH', by using for-loop in MATLAB GUI or if you know an alternative way to do it. After I started to run the code, nothing happened although no error message has come. Also I hope that some of you get solutions of my problem.
Thank you very much in advance!
function nightly_simulation_Callback(hObject, eventdata, handles)
% hObject handle to nightly_simulation (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
PATH = 'C:\Users\xxx\Documents\Saved_Models';
files=dir([PATH,'*.slx']);
fileNames={files.name};
fileNames=sort(fileNames);
nFiles=numel(fileNames);
selection = questdlg('Sure to start?',...
'Confirmation',...
'Yes','No','Yes');
switch selection
case 'Yes'
for i=1:nFiles
x = [PATH,fileNames{i}];
open_system(x);
sim(x);
end
case 'No'
return
end

Answers (1)

OK
OK on 31 Jul 2019
I did it by rewriting the code like this:
function nightly_simulation_Callback(hObject, eventdata, handles)
% hObject handle to nightly_simulation (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
PATH = 'C:\Users\xxx\Documents\Saved_Models';
files = dir( fullfile(PATH,'*.slx') ); %# list all *.slx files
fileNames = {files.name}';
fileNames=sort(fileNames);
nFiles=numel(fileNames);
selection = questdlg('Sure to start?',...
'Confirmation',...
'Yes','No','Yes');
switch selection
case 'Yes'
for i=1:nFiles
x = fullfile(PATH, fileNames{i});
open_system(x);
sim(x);
end
case 'No'
return
end

This question is closed.

Community Treasure Hunt

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

Start Hunting!