How to run Simulink Model File From Script file ?

I have a GUI where I choose a file to be simulated using a browse Option(Push Button), Am not able to simulate the file which I choose using the codes but if I specifically write the code like sim ('test_new01') am able to simulate. But when its sim('filename') am not able to simulate the file (that line code because name changes every time I choose different model file)

답변 (2개)

KL
KL 2017년 5월 23일

0 개 추천

save the return in a cell array and use it.
filename{1,1} = get(handles.edit1,'String');
sim(filename{1,1});

댓글 수: 3

Am getting error to this Code , my code to browse is as follow ,
[filename,pathname] = uigetfile('*.*','Choose the file'); % for complete path [pathstr,name,ext]=fileparts(filename) %just for the file name
followed by uor code
filename{1,1} = get('handles.edit1','String'); sim(filename{1,1});
in your case,
sim([pathname filename]);
Its working fine in the script file, but when it is put in GUI-mfile, it's not working !!!!

댓글을 달려면 로그인하십시오.

Nithesh Nayak
Nithesh Nayak 2018년 6월 5일
편집: Nithesh Nayak 2018년 6월 5일

0 개 추천

This worked fine inside a GUI button
if true
[filename,pathname] = uigetfile('simulink');% to browse the file
[pathstr,name,ext]=fileparts(filename) %to get only the name of selected file
load_system(name)
cs = getActiveConfigSet(name);
model_cs = cs.copy;
global name %Declaring globally so as to use all over the Programm
sim(name);% to simulate the model
end

카테고리

도움말 센터File Exchange에서 Simulink에 대해 자세히 알아보기

질문:

2017년 5월 23일

편집:

2018년 6월 5일

Community Treasure Hunt

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

Start Hunting!

Translated by