matlab 画图函数的实例

clc,
clear all;
close all;

A=[1 2 3;4 5 6;7 8 9];
B=rot90(A);
C=fliplr(A);
D=magic(3);
D(:,10)=2;



%%
% %画图
% x=linspace(0,2*pi,50);
% y=cos(x);
% plot(x,y,'r.')
% plot(x,y,'*')
% y=cos(x);
% xlabel('x');
% ylabel('y');
% axis([0 1 0 1])
% title('我是小黄鸡');
% legend('x轴','y轴')
% plot(x,y,'r+',x,sin(x),'mo')


%%
% 绘制双Y轴曲线
% x=linspace(0,2,201);%生成等间距的采样数据
% subplot(131);
% [Ax1,h1,h2]=plotyy(x,sin(x*2),x,sinh(exp(x)));%绘制双Y轴曲线
% xlabel('我是X轴');
% ylabel('我是Y轴');
% subplot(132);
% [Ax2,h1,h2]=plotyy(x,abs(sin(x)),x,sinh(x),@semilogy);%绘制双Y轴曲线
% xlabel('b','Fontsize',12,'fontname','Times New Roman');%x轴标注
% box on;
% subplot(133);
% [Ax3,h1,h2]=plotyy(10*[x*10+1],abs(sin(x)),10*[x*10+1],sinh(x),'loglog',@semilogx);%绘制双Y轴曲线
% axis([Ax1,Ax2,Ax3],'square');
% xlabel('(c)','Fontsize',12,'fontname','Times New Roman');
% set([Ax1,Ax2,Ax3],'Fontsize',10);


%%
% logglog函数
% x1=logspace(-1,2);
% subplot(131);
% loglog(x1,exp(x1),'s-');
% title('logglog函数绘图');
% grid on;
% x2=0:0.1:10;
% subplot(132);
% semilogx(10.^x2,x2,'r-.');
% title('semilogx函数');
% subplot(1,3,3);
% semilogy(10.^x2,'rd');
% title('semilogy函数');


 %%
%  x=0:0.01:1;
%  y=sin(tan(pi*x));
%  subplot(121);
%  plot(x,y);
%  title('plot绘图');
%  subplot(122);
%  fplot('sin(tan(pi*x))',[0,1],1e-4);
%  title('fplot函数绘图');


 %%
%  %绘制参数函数的图形
%  subplot(2,1,1);
%  ezplot('cos(5*t)','sin(3*t)',[0,2*pi]);%绘制参数 函数效果图
%  grid on;
%  subplot(2,1,2);
%  ezplot('5*x^2+25*y^2=6',[-1.5,1.5,-1,1]);

 %%
% %  gin input 读取点 按Enter结束
% x1=0:pi./100:2*pi;
% plot(x1,cos(x1));
% n=10;
% % [x,y]=ginput(n)%鼠标读取
% % [x,y]=ginput%无限读取
% [x,y,button]=ginput%鼠标左右中的读取


 %%
% %  为绘制的图添加标注说明
%  x=-pi:pi/20:pi;
%  plot(x,cos(x),'-ro',x,sin(x),'-.b');
%  h=legend('cos_x','sin_x',2);
%  set(h,'Interpreter','none');
%  xlabel('x');
%  ylabel('y');
%  title('绘制两条曲线');
%  grid on;%添加网格线
%  box off;%删除框图  是否添加 外框
%  hold on;
%  stem(x,sin(x),'-g*')


%%
% %在一个图形窗口中以子图形式绘制多条曲线
% x=linspace(0,2*pi,60);
% y=sin(x);
% z=cos(x);
% t=sin(x)./(cos(x)+eps);
% c=cos(x)./(sin(x)+eps);
% subplot(2,2,1);%只选择22列的第一个
% stairs(x,y);
% title('sin(x)-1');
% axis([0 2*pi -1 1]);
% 
% subplot(2,1,2);%只选择22列的第二个
% stem(x,y);
% title('sin(x)-2');
% axis([0 2*pi -1 1]);
% 
% subplot(4,4,3);%只选择44列的第三个
% plot(x,y);
% title('sin(x)');
% axis([0 2*pi -1 1]);
% subplot(4,4,7);%只选择44列的第7个
% plot(x,y);
% title('sin(x)');
% axis([0 2*pi -1 1]);
% subplot(4,4,8);%只选择44列的第8个
% plot(x,y);
% title('sin(x)');
% axis([0 2*pi -1 1]);


%%
% %误差量图
% x=linspace(0,2*pi,20);
% y=sin(x);
% z=std(y)*ones(size(x));
% errorbar(x,y,z)


%%
% %画出条形图
% x=1:15;
% y=rand(size(x));
% bar(x,y);
% xlabel('条形图显示');


%%
% %极地型坐标
% theta=linspace(0,2*pi);
% r=cos(2*theta);
% polar(theta,r)


%%
% hist函数显示资料的分段情况和统计特性
x=randn(999,1);%randn产生高斯随机数
hist(x,50);%50代表长条的个数


%%
% %stem函数产生针状图,绘制数位信号
% x=linspace(0,10,100);
% y=sin(x).*exp(-x/4);
% stem(x,y);


%%
% % stairs函数可以画出阶样图
% x=linspace(0,10,30);
% y=sin(x).*exp(-x/4);
% stairs(x,y)


%%
%fill函数将资料点视为多边形点,并将此多边形涂上颜色
% x=linspace(0,10,100);
% y=sin(x).*exp(-x/4);
% fill(x,y,'c')


%%
% % feather函数将每一个资料点视为复数,并以箭头画出
% theta=linspace(0,2*pi,40);
% z=cos(theta)+i*sin(theta);
% feather(z)


%%
% % compass和feather函数很像,只是每个箭头的起点都在圆内
% theta=linspace(0,2*pi,40);
% z=cos(theta)+i*sin(theta);
% compass(z)


%%
% % 利用plot3、mesh、meshc、和meshz分别画出三维网格图
% [X,Y]=meshgrid(-3:.5:3);
% Z=2*X.^2-3*Y.^2;
% subplot(2,2,1);
% plot3(X,Y,Z)
% title('plot3');
% 
% subplot(2,2,2);
% mesh(X,Y,Z)
% title('mesh')
% 
% subplot(2,2,3);
% meshc(X,Y,Z);
% title('meshc');
% 
% subplot(2,2,4);
% meshz(X,Y,Z);
% title('meshz');


%%
% 利用hidden函数显示3维图形的透视效果
% [X,Y]=meshgrid(-8:.5:8);
% R=sqrt(X.^2+Y.^2)+eps;
% Z=sin(R)./R;
% subplot(121);
% mesh(X,Y,Z)
% hidden on;
% subplot(122);
% mesh(X,Y,Z)
% hidden on;



%%
% %利用surf函数绘制三维表面图
% [x,y]=meshgrid(-3:1/8:3);
% z=peaks(x,y);
% subplot(221);
% surf(z);
% title('绘制surf(z)绘图的形式');
% subplot(222);
% surf(x,y,z);
% title('绘制surf(x,y,z)绘图的形式');
% subplot(223);
% surfl(x,y,z);
% title('绘制surfl(x,y,z)绘图的形式');
% 
% subplot(224);
% surfc(z);
% title('绘制surfc(x,y,z)绘图的形式');



%%
% %标准三维曲面图的绘制
% t=0:pi/10:2*pi;
% [X,Y,Z]=cylinder(2+cos(t));
% subplot(2,2,1);
% surf(X,Y,Z);
% title('圆柱图');
% axis square
% 
% [x,y,z]=ellipsoid(0,0,0,5.9, 3.25, 3.25 ,30);
% subplot(2,2,2);
% surfl(x,y,z);
% title('椭圆');
% colormap hsv
% axis equal
% subplot(2,2,3);
% surf(x,y,z);
% axis equal
% title('球体');
% [x,y,z]=peaks;
% subplot(2,2,4);
% meshz(x,y,z);
% title('多峰图');


%%
% %三维等高图
% X=[0 1 1 2;1 1 2 2;0 0 1 1];
% Y=[1 1 1 1;1 0 1 0;0 0 0 0];
% Z=[1 1 1 1;1 0 1 0;0 0 0 0];
% c=[0.5 1 1 0.5;1 0.5 0.5 0.1667;0.333 0.333 0.5 0.5];
% subplot(121);
% fill3(X,Y,Z,c);
% title('填充图');
% [X,Y,Z]=peaks;
% subplot(122);
% contour3(X,Y,Z,20);
% title('等高线图');
% set(gcf,'color','w');


%%
%从不同视点绘制多峰函数曲线
% subplot(221);
% mesh(peaks);
% view(-37.5,30);
% title('azimuth=37.5,elevation=30');
% subplot(222);
% mesh(peaks);
% 
% view(0,90);
% title('azimuth=0,elevation=90');
% subplot(223);
% mesh(peaks);
% view(90,0);
% title('azimuth=90,elevation=0');
% subplot(224);
% mesh(peaks);
% view(-7,-12);
% title('azimuth=-7,elevation=-12');





























  • 1
    点赞
  • 6
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值