Info

Cette question est clôturée. Rouvrir pour modifier ou répondre.

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 vue (au cours des 30 derniers jours)
OK
OK le 31 Juil 2019
Clôturé : MATLAB Answer Bot le 20 Août 2021
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

Réponses (1)

OK
OK le 31 Juil 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

Cette question est clôturée.

Community Treasure Hunt

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

Start Hunting!

Translated by