matlab - matlab 从 GUI 按钮运行脚本文件
问题描述
我有一个脚本文件,想从 gui 按钮运行它,它不起作用。
错误是:
Undefined variable "classifyDeeb" or class "classifyDeeb.m".
Error in Train>pushbutton2_Callback (line 113)
classifyDeeb.m
Error in gui_mainfcn (line 96)
feval(varargin{:});
Error in Train (line 42)
gui_mainfcn(gui_State, varargin{:});
Error in @(hObject,eventdata)Train('pushbutton2_Callback',hObject,eventdata,guidata(hObject))
Error while evaluating uicontrol Callback
------------------
scrip file code `load deeb;
trdata=[deeb(1:8,2:6);deeb(11:18,2:6)];
gr=[deeb(1:8,1);deeb(11:18,1)];
testdata=[deeb(9:10,2:6);deeb(19:20,2:6)];
svmstr=svmtrain(trdata,gr);
result = svmclassify(svmstr,testdata);
output = result;`
----------------------------
the pushbutton2_Callback code is :
% --- Executes on button press in pushbutton2.
function pushbutton2_Callback(hObject, eventdata, handles)
% hObject handle to pushbutton2 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
classifyDeeb.m
脚本文件、图形和矩阵数据 (deeb.mat) 文件位于同一文件夹中。请帮助提前感谢您的帮助
解决方案
两个选项:您可以run()
在 m 文件名上使用。如果脚本位于另一个目录中,您甚至可以包含脚本的完整路径。
function pushbutton2_Callback(hObject, eventdata, handles)
run('classifyDeeb.m')
或在没有扩展名的情况下调用它。只要它位于 Matlab 的路径中,这将起作用。
function pushbutton2_Callback(hObject, eventdata, handles)
classifyDeeb
推荐阅读
- javascript - 屏幕阅读器可访问的 React 图表库
- python - 查找图中顶点之间的所有路径
- maven - 未能执行目标 com.e-gineering:gitflow-helper-maven-plugin:2.2.0:enforce-versions
- asp.net - 在 Azure 上部署后设计混乱
- python - 如何优化 django 查询中的注释?
- python - 如何使用 Python 将表格转换为特定的 XML 格式?
- javascript - 链接到 javascript 的 href
- azure - 如何确保新创建的 prod azure 资源被策略锁定?
- php - Laravel - 服务容器中单例和实例绑定之间的区别
- node-red - 带有 TTS 响应的出站呼叫,包括 DTMF 输入