Run a simulink/script from a pushbutton
Show older comments
hi
i've a script in a PB_function and when i push the button it shows me a lot off errors.Running the originar script without the PB it works but when i use in PB_function doesn't work:
??? Error using ==> gui_passdata>pb2_call at 438
Error due to multiple causes.
Caused by:
Error using ==> gui_passdata>pb2_call at 438
Error evaluating parameter 'VariableName' in
'modelo_pilha1/B': Undefined function or variable 'P1'.
in the scrip i've a simulink model that uses the variable P1 but i don't change anything and it doesn't work.
a(1)=5*10^(-3);
b(1)=5*10^(-2);
PP1=a(1)+(b(1)-a(1))*rand;
P1=[t PP1];
to run the simulink model
load_system('modelo_pilha1'); % correr simulink e obter Vsimulado
sim('modelo_pilha1');
Accepted Answer
More Answers (1)
Kaustubha Govind
on 28 Sep 2011
By default, Simulink looks for parameter variables in the base workspace. You variable P1 is created in the function workspace, where Simulink isn't looking. To have it looks for P1 in the current/function workspace, use:
load_system('modelo_pilha1');
opt=simset('SrcWorkspace','current');
sim('modelo_pilha1',opt);
Alternatively, you can follow Tabrez's suggestion of loading the variables into the base workspace.
3 Comments
Nu9
on 28 Sep 2011
TABOUNI Khadidja
on 22 May 2017
did this answer hel you?
TABOUNI Khadidja
on 22 May 2017
Edited: TABOUNI Khadidja
on 22 May 2017
i need to do the same thing but save whatever the sim func gives me
Categories
Find more on Modeling in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!