MATLAB 绘图一

一、绘图

MATLAB 最牛的地方就是绘图,这个才是其他工具不能代替的主要原因。

 

 this:

x=11;
y=49;
plot(x,y,'r*');
axis([9 12 35 55])

xlabel('time');
ylabel('tem');
title('first_plot');

ex2:

x=1:5;
y=[9 23 12 4 9];
% 这中情况 x 和y 必须长度一样的长,不然程序不能运行
plot(x,y,'g*-');

xlabel('time');
ylabel('tem');
title('first_plot');

 点的形状 

 

x=1:5;
y=[9 23 12 4 9];
% 这中情况 x 和y 必须长度一样的长,不然程序不能运行
plot(x,y,'g*-');
hold;  #在第一plot的基础上继续画图
plot(x,x+1,'r*-');

xlabel('time');
ylabel('tem');
title('first_plot');

 绘图叠加:

x=1:5;
y=[9 23 12 4 9];
% 这中情况 x 和y 必须长度一样的长,不然程序不能运行
% ishold =false;
hold on;
plot(x,y,'g*-');


% ishold =true;
plot(x,x+1,'r*-');

%  第三个画图
% ishold =true;
plot(x,x+5,'b*-');

hold off;
xlabel('time');
ylabel('tem');
title('first_plot');

 重新打开一个画布:

x=1:5;
y=[9 23 12 4 9];
% 这中情况 x 和y 必须长度一样的长,不然程序不能运行
% ishold =false;
hold on;
plot(x,y,'g*-');


% ishold =true;
plot(x,x+1,'r*-');

%  第三个画图
% ishold =true;
plot(x,x+5,'b*-');

hold off;
xlabel('time');
ylabel('tem');
title('first_plot');


figure();
% 重新打开一个新的画布
x=1:5;
y=[9 23 12 4 9];
plot(x,x+1,'b*-');
title('-----second----');

 召唤某一个figure

 figure(1);

x=1:5;
y=[9 23 12 4 9];
% 这中情况 x 和y 必须长度一样的长,不然程序不能运行
% ishold =false;
hold on;
plot(x,y,'g*-');


% ishold =true;
plot(x,x+1,'r*-');

%  第三个画图
% ishold =true;
plot(x,x+5,'b*-');

hold off;
xlabel('time');
ylabel('tem');
title('first_plot');


figure();
% 重新打开一个新的画布
x=1:5;
y=[9 23 12 4 9];
plot(x,x+10,'b*-');
title('-----second----');


figure(1);
% 这里又开始启用第一个画布
hold on;

plot(x,x*2,'r*-');

 

 clf 清除掉所有的figure 

close(1) 关闭第一个画布

subPlot的使用:

x=1:5;
y=[9 23 12 4 9];
% 这中情况 x 和y 必须长度一样的长,不然程序不能运行
% ishold =false;
hold on;
plot(x,y,'g*-');


% ishold =true;
plot(x,x+1,'r*-');

%  第三个画图
% ishold =true;
plot(x,x+5,'b*-');

hold off;
xlabel('time');
ylabel('tem');
title('first_plot');

close all;
figure(1);

subplot(3,1,1)
% 重新打开一个新的画布
hold on;
x=1:5;
y=[9 23 12 4 9];
plot(x,x+10,'b*-');
title('-----1----');

plot(x,x*3,'b*-');
title('-----1----');
hold off;

subplot(3,1,2)
plot(x,x*2,'r*-');
title('-----2----');

subplot(3,1,3)
plot(x,x*2,'r*-');
title('-----3----');

 legend 函数的使用:

bar的使用:

 

plot : 

 总结:

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值