Matlab GUI 多个 axes 画图

 时间:2026-04-21 16:27:52

1、创建一个GUI神码的不说了。直接进入正题。

画好了就如下图。问题就是,如果把两幅图分别画在两个axes上

Matlab GUI 多个 axes 画图

2、直接放代码了:

重点处加粗了。

% --- Executes on button press in pushbutton2.

function pushbutton1_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)

t = -5:.1:5;

y = sinc(t);

plot(handles.axes1,t,y,'gd');

legend(handles.axes1,'sin(x)/x');

% --- Executes on button press in pushbutton1.

function pushbutton2_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)

t = 1:.1:10;

x = sin(t);

y = cos(t);

plot3(handles.axes2,t,x,y,'r*');

legend(handles.axes2,'t-x-y');

3、plot(handles.axes1,t,y,'gd');

plot3(handles.axes2,t,x,y,'r*');

关键的就是这两句了,其他情况也是类似的。

结果就如下了

Matlab GUI 多个 axes 画图

  • matlab中怎样添加图例
  • matlab线型和颜色设置
  • Matlab GUI弹出式菜单(popupmenu)控件的使用
  • MATLAB R2015b中注释汉字复制到word上出现乱码
  • MATLAb怎样设置坐标轴
  • 热门搜索
    文化公司名称大全 广汽传祺车怎么样 意外保险怎么报销 天风证券怎么样 河北旅游景点大全 嘴角长疱疹怎么办 面部皮肤松弛怎么办 鸡怎么炖好吃又营养 乐山大佛简介 樱花油烟机怎么样