Info

La pregunta está cerrada. Vuélvala a abrir para editarla o responderla.

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 visualización (últimos 30 días)
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

Respuestas (1)

OK
OK el 31 de Jul. de 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

La pregunta está cerrada.

Community Treasure Hunt

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

Start Hunting!

Translated by