How to run Simulink Model File From Script file ?

3 visualizaciones (últimos 30 días)
Nithesh Nayak
Nithesh Nayak el 23 de Mayo de 2017
Editada: Nithesh Nayak el 5 de Jun. de 2018
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)

Respuestas (2)

KL
KL el 23 de Mayo de 2017
save the return in a cell array and use it.
filename{1,1} = get(handles.edit1,'String');
sim(filename{1,1});
  3 comentarios
KL
KL el 23 de Mayo de 2017
in your case,
sim([pathname filename]);
Nithesh Nayak
Nithesh Nayak el 24 de Mayo de 2017
Its working fine in the script file, but when it is put in GUI-mfile, it's not working !!!!

Iniciar sesión para comentar.


Nithesh Nayak
Nithesh Nayak el 5 de Jun. de 2018
Editada: Nithesh Nayak el 5 de Jun. de 2018
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

Categorías

Más información sobre Model, Block, and Port Callbacks en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by