我正在尝试使用Matlab编写一个GUI,让用户输入点作为输入和它们之间的连接。
我有5个Matlab文件 - screen1.m,screen2.m,screen3.m,screen4.m,globalParams.m
在globalParams中,我有全局参数,所以我可以从屏幕GUI到屏幕GUI使用它们。在screen1中,用户输入节点的数量(例如5)。当他按下“下一个”按钮时,回调函数调用“screen2();
”。在screen2.m中,用户输入(x,y)坐标,当他按下“下一个”按钮时,回调函数调用“screen3();
”。
现在我要求他填写节点i到节点j之间的连接。(他需要填写节点i和j的数字)。如果只有一个连接,他将按下“完成”按钮,回调函数将调用“screen4();
”,一切都很好。否则(有多个连接),他按下“下一个”按钮,回调函数调用“screen3();
”。
因此,当我们有多个连接时,我在再次调用screen3时遇到问题。
还有一种方法,当我调用下一个屏幕时关闭上一个屏幕吗? 因为当我们找到一种方法来一遍又一遍地调用screen3时,将会有大量的GUI打开,这可能会让用户感到困惑和烦恼。
一些代码:
在screen1中,下一个按钮:
function pushbutton1_Callback(hObject, eventdata, handles)
% hObject handle to pushbutton1 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
screen2();
在screen2中,下一个按钮:
function pushbutton1_Callback(hObject, eventdata, handles)
% hObject handle to pushbutton1 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
screen3();
在屏幕3中,点击下一步按钮,然后是完成按钮。
function pushbutton1_Callback(hObject, eventdata, handles)
% hObject handle to pushbutton1 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
screen3();
% --- 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)
screen4();
在screen3中,我是如何使用2个节点之间的连接的:
function edit2_Callback(hObject, eventdata, handles)
% hObject handle to edit2 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Hints: get(hObject,'String') returns contents of edit2 as text
% str2double(get(hObject,'String')) returns contents of edit2 as a double
global hopsMatrix;
i = str2num(get(handles.edit2, 'string'));
j = str2num(get(handles.edit1, 'string'));
hopsMatrix(i,j) = 1;
screen3()
会有问题?是出现了错误,还是无法正常工作? - scenia