一、绘图
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 :
总结: