Running a Simulink Model from a function called by a GUI
1 次查看(过去 30 天)
显示 更早的评论
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 个评论
Fangjun Jiang
2020-1-20
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.
回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Programmatic Model Editing 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!