您如何使用“保持"状态使用MATLAB GUI? [英] How do you use "hold on" with MATLAB GUI?

查看:210
本文介绍了您如何使用“保持"状态使用MATLAB GUI?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在与GUIDE一起制作一个很大的GUI.我想在同一图上绘制两组数据.对于常规的MATLAB代码,我会写:

I am working with GUIDE to make a big GUI. I would like to plot two sets of data on the same plot. For regular MATLAB code I would write:

time = 1:10;
data1= (1:10).*2;
data2= (1:10).*3;
figure;
plot(t,data1);
hold on;
plot(t,data2);
hold off;

但是,这不适用于GUI系统.使用GUI,我输入:

However, this does not work with the GUI system. With the GUI I am typing:

time = 1:10;
data1= (1:10).*2;
data2= (1:10).*3;
plot(handles.axes1,t,data1);
hold on;
plot(handles.axes1,t,data2);
hold off;

但这不起作用. data2刚好覆盖了前一个图.任何帮助,将不胜感激.谢谢你.

But this does not work. data2 just over writes the previous plot. Any help would be appreciated. Thank you.

解决方案:

time = 1:10;
data1= (1:10).*2;
data2= (1:10).*3;
plot(handles.axes1,x,y);
hold(handles.axes1)
plot(handles.axes1,x,z);

推荐答案

如果这是您要绘制的唯一东西,只需使用没有轴手柄的绘制函数(默认情况下它们具有相同的手柄):

If this is the only thing you want to plot, just use plot functions without axes handle (they will have the same handle by default):

t = 1:10;
data1= (1:10).*2;
data2= (1:10).*3;
plot(t,data1);
hold on;
plot(t,data2);
hold off;

这篇关于您如何使用“保持"状态使用MATLAB GUI?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆