2020-11-17

MATLAB绘图函数

loglog()

x=logspace(-1,1,100);
y=x.^2;
subplot(2,2,1);
plot(x,y);
title('Plot');
subplot(2,2,2);
semilogx(x,y);       %对x取对数
title('Semilogx');
subplot(2,2,3);
semilogy(x,y);       %对y取对数
title('Semilogy');
subplot(2,2,4);
loglog(x,y);         %对x,y分别取对数
title('Loglog');

图1
加网格

set(gca,'XGrid','on');

图2

plotyy()

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);
set(get(AX(1),'Ylabel'),'String','Left Y-axis');
set(get(AX(2),'Ylabel'),'String','Right Y-axis');
title('Labeling plotyy');
set(H1,'LineStyle','--');set(H2,'LineStyle',':');

图3

Histogram

 y=randn(1,1000);
subplot(2,1,1);
hist(y,10);
title('Bins=10');
subplot(2,1,2);
hist(y,50);
title('Bins=50');

图4## Bar Charts

x=[1 2 5 4 8];y=[x;1:5];
subplot(1,3,1);bar(x);title('A bargraph of vector x');
subplot(1,3,2);bar(y);title('A bargraph of vector y');
subplot(1,3,3);bar3(y);title('A 3D bargraph ');

图5

stack and horizontal charts

x=[1 2 5 4 8];y=[x;1:5];
subplot(1,2,1);
bar(y,'stacked');
title('stacked');
subplot(1,2,2);
barh(y);
title('Horizontal');

图6

pie charts

a=[10 5 20 30];
subplot(1,3,1);pie(a);
subplot(1,3,2);pie(a,[0,0,0,1]);
subplot(1,3,3);pie3(a,[0,0,0,1]);

图7

polar chart

x=1:100;theta=x/10;r=log10(x);
subplot(1,4,1);polar(theta,r);
theta=linspace(0,2*pi);r=cos(4*theta);
subplot(1,4,2);polar(theta,r);
theta=linspace(0,2*pi,6);r=ones(1,length(theta));
subplot(1,4,3);polar(theta,r);
theta=linspace(0,2*pi);r=1-sin(theta);
subplot(1,4,4);polar(theta,r);

图8

stairs and stem charts

x=linspace(0,4*pi,40);y=sin(x);
subplot(1,2,1);stairs(y);
subplot(1,2,2);stem(y);

图9

hold on;
t=linspace(0,10);y=sin((pi*t.^2)/4);
plot(t,y,'b');
stem(t,y,'r');
hold off;

图10

fill()

t=(1:2:15)'*pi/8;x=sin(t);y=cos(t);
fill(x,y,'r');axis square off;
text(0,0,'STOP','Color','w','FontSize',80,'FontWeight','bold','HorizontalAlignment','center');

图11

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

Moring_w

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值