Show figure

87 次查看(过去 30 天)
Cruise
Cruise 2011-11-24
Hi everybody.
I have a GUI to plot a 3D graph.My problem is graph showed in GUI.I want to show graph in separate figure.Thank all advice. It's my code callback function of pushbutton.
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)
a1=str2num(get(handles.x1,'String'));
b1=str2num(get(handles.y1,'String'));
c1=str2num(get(handles.z1,'String'));
a2=str2num(get(handles.x2,'String'));
b2=str2num(get(handles.y2,'String'));
c2=str2num(get(handles.z2,'String'));
a3=str2num(get(handles.x3,'String'));
b3=str2num(get(handles.y3,'String'));
c3=str2num(get(handles.z3,'String'));
plot3 ([a1 a2 a3],[b1 b2 b3],[c1 c2 c3],'Marker','o','LineStyle','-');
grid on
rotate3d on

采纳的回答

Walter Roberson
Walter Roberson 2011-11-24
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)
a1=str2num(get(handles.x1,'String'));
b1=str2num(get(handles.y1,'String'));
c1=str2num(get(handles.z1,'String'));
a2=str2num(get(handles.x2,'String'));
b2=str2num(get(handles.y2,'String'));
c2=str2num(get(handles.z2,'String'));
a3=str2num(get(handles.x3,'String'));
b3=str2num(get(handles.y3,'String'));
c3=str2num(get(handles.z3,'String'));
f = figure();
ax = axes('Parent',f); %corrected from my original version
plot3 (ax, [a1 a2 a3],[b1 b2 b3],[c1 c2 c3], 'Marker','o','LineStyle','-');
grid(ax, 'on')
rotate3d(ax, 'on')
  3 个评论
Walter Roberson
Walter Roberson 2011-11-25
编辑:Randy Souza 2012-8-15
Cruise, try instead
ax = axes('Parent',f)
Cruise
Cruise 2011-11-25
编辑:Randy Souza 2012-8-15
It's OK. Thanks a lot.

请先登录,再进行评论。

更多回答(1 个)

Ricky
Ricky 2011-11-24
编辑:Randy Souza 2012-8-15
You can insert a command figure in between the graph that you plot like this:
a1=str2num(get(handles.x1,'String'));
figure(1);
b1=str2num(get(handles.y1,'String'));
figure(2);
...
Is that what you are after?

类别

Help CenterFile Exchange 中查找有关 Graphics Object Properties 的更多信息

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by