Running a Simulink Model from a function called by a GUI
2 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Pedro Augusto de Castro e Castro
am 16 Jan. 2020
Kommentiert: Fangjun Jiang
am 20 Jan. 2020
Hello everyone,
I want to call a Simulink Model from inside a function that is called by a button press in a GUI. However, I've got a problem that does not occur when I run this model from a script. (simulaInv is the function, simulaInv_v2 is the GUI and the model is inversor_2n).
Error using simulaInv (line 131)
Error due to multiple causes.
Error in simulaInv_v2>simular_Callback (line 362)
simulaInv(hObject, handles);
Error in gui_mainfcn (line 95)
feval(varargin{:});
Error in simulaInv_v2 (line 42)
gui_mainfcn(gui_State, varargin{:});
Error in matlab.graphics.internal.figfile.FigFile/read>@(hObject,eventdata)simulaInv_v2('simular_Callback',hObject,eventdata,guidata(hObject))
Caused by:
Error using simulaInv (line 131)
Invalid setting for fixed-step size (8.1380208333333339E-7) in model 'inversor_2n'. All sample times in your model must be an integer multiple of the fixed-step size.
Error using simulaInv (line 131)
The sample time period (1.403107040229885E-7) of 'inversor_2n/powergui/EquivalentModel1/State-Space' is not an integer multiple of the fixed step size (8.1380208333333339E-7) specified for model.
Error while evaluating UIControl Callback.
I don't understand because if I run the same model using a script it runs just fine, without any errors.
5 Kommentare
Pedro Augusto de Castro e Castro
am 17 Jan. 2020
Bearbeitet: Pedro Augusto de Castro e Castro
am 20 Jan. 2020
Fangjun Jiang
am 20 Jan. 2020
It seems there is nothing wrong calling to run the simulation from GUI. The problem is the model with the parameters. The error message is clear. You can't have a fixed step size as 8.1E-7 while there is a sample time of 1.4E-7 in the model.
All sample times in your model must be an integer multiple of the fixed-step size.
If you sample time is 1.4E-7, then the fixed step size has to be at least 1.4E-7, or better much smaller, but must be an integer fraction of the sample time, such as 7E-8, 3.5E-8, etc.
Antworten (0)
Siehe auch
Kategorien
Mehr zu Programmatic Model Editing finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!