我有一个 Gui 和一个 Simulink 模型,我想在 Gui 的文本字段中输入一些值,然后按开始按钮,之后,我的 simulink 模型应该采用这些值并运行,结果应该显示在 gui 静态文本中。
到 simulink:我必须不断的块,他们的名字是 kraft 和 flaeche。并且进入块的参数是k和f。
好的,现在我想在 gui 中编辑 k 和 f 的值。这是我的代码:
function kraft_Callback(hObject, eventdata, handles)
kraft_value = str2num(get(hObject,'String'));
if (isempty(kraft_value))
set(hObject,'String','0')
end
guidata(hObject, handles);
function flaeche_Callback(hObject, eventdata, handles)
flaeche_value = str2num(get(hObject,'String'));
if (isempty(flaeche_value))
set(hObject,'String','0')
end
guidata(hObject, handles);
function start_Callback(hObject, eventdata, handles)
k= str2double(get(hObject,'string'));
f= str2double(get(hObject,'string'));
sim('Steifigkeit');
function static_CreateFcn(hObject, eventdata, handles)
但我得到这些错误:
Error using Gui>start_Callback (line 215)
Error due to multiple causes.
Error in gui_mainfcn (line 96)
feval(varargin{:});
Error in Gui (line 17)
gui_mainfcn(gui_State, varargin{:});
Error in @(hObject,eventdata)Gui('start_Callback',hObject,eventdata,guidata(hObject))
Caused by:
Error using Gui>start_Callback (line 215)
Error evaluating parameter 'Value' in 'Steifigkeit/f'
Error using Gui>start_Callback (line 215)
Undefined function or variable 'f'.
Error using Gui>start_Callback (line 215)
Error evaluating parameter 'Value' in 'Steifigkeit/k'
Error using Gui>start_Callback (line 215)
Undefined function or variable 'k'.
有人可以帮我吗