1.advanced 2D plots
- logspace(a,b,n)
生成n个10^a到10^b个对数等距点
(两极(10^a、10^b)取对数,再除n,得n个等距结果,再将这些结果取指数,指数的底为对数的底,得到n个等距点(等距点指取完对数之后等距,其本身不等距)
x=logspace(-1,1,100);
y=x.^2;
subplot(2,2,1);
plot(x,y);
set(gca,'XGrid','on');%加网格
title('Plot');
subplot(2,2,2);
semilogx(x,y);
set(gca,'XGrid','on');%加网格
title('Semilogx');
subplot(2,2,3);
semilogy(x,y);
set(gca,'XGrid','on');%加网格
title('Semilogy');
subplot(2,2,4);
loglog(x,y);
title('Loglog');
set(gca,'XGrid','on');%加网格
- [AX,h1,h2]=plotyy(x,y1,x,y2)
x=0:0.01:20;
y1=200*exp(-0.05*x).*sin(x);
y2=0.8*exp(-0.5*x).*sin(10*x);
[AX,h1,h2]=plotyy(x,y1,x,y2);
[AX,h1,h2]=plotyy(x,y1,x,y2);
set(get(AX(1),'Ylabel'),'String','200*exp(-0.05*x)*sin(x)');
set(get(AX(2),'Ylabel'),'String','0.8*exp(-0.5*x)*sin(10*x)');
title('Labeling plotyy');
set(h1,'LineStyle','--');
set(h2,'LineStyle',':');
>>
- Histogram——直方图
function |
功能 |
randn(row,col,lay) |
生成由rowcollay个满足正态分布的随机数组成的array |
randn(n) |
生成n维matrix |
randn(row,col) |
生成row行,col列matrix |
randn(1,col) |
生成col维vector |
y=randn(1,1000);
subplot(2,1,1);
hist(y,10);
title('Bins=10');
subplot(2,1,2)
hist(y,50);
title('Bins=50');
- bar chart
bar(vector)
bar(matrix)% bar(每一个行向量)
bar3(vector)
bar3(matrix)
bar(para,‘stacked’) %堆叠起来(栈)
barh(para) %horizontal 水平
x=[1 2 5 4 8];
y=[x;1 2 3 4 5