暂无图片
暂无图片
暂无图片
暂无图片
暂无图片

Matlab绘图

Hello 帅帅 2020-07-12
313

线条风格

图片组件

  1. 画图窗口打开

    1. figure

  2. 设置标题

    1. title

  3. 坐标显示:

    1. grid on

    2. grid off

  4. 命名坐标轴

    1. xlabel('x轴')

    2. ylabel('y轴')

  5. 内嵌文字

    1. text(x,y,str)

  6. 标注曲线

    1. legend(str,str)

  7. 设置坐标轴

    1. axis([xmin xmax ymin ymax]) 设定最大和最小值

    2. axis (’square’)   将当前坐标图形设置为方形

    3. axis (’equal’)    两个坐标因子设成相等

    4. axis (’off’)      关闭坐标系统

    5. axis (’on’)       显示坐标系统

  8. 设置子图

    1. subplot(x,y,n)

示例:

    figure                                 %创建图形窗口
    subplot(2,3,1) %选择23列第1个子窗口
    plot(0,0,'o') %画点(圈)
    subplot(2,3,2),plot([-2,2],[0,0]) %选择23列第2个子窗口,画水平实线
    subplot(2,3,3),plot([0,0],[-2,2],'--^')%选择23列第3个子窗口,画竖直虚线
    subplot(2,3,4),plot([-3,1],[-2,2],'-.x')%选择23列第4个子窗口,画斜点虚线
    grid %加网格
    x=-2:0.1:2; %横坐标向量
    y=x.^2; %纵坐标向量
    subplot(2,3,5),plot(x,y,'.-',x,-y,':*')%选择23列第5个子窗口,画上下抛物线
    subplot(2,3,6),plot(y,x,'p-r',-y,x,':hc')%选择23列第6个子窗口,画左右抛物线
    x=logspace(-1,2);
    loglog(x,exp(x),'-')
    grid on %标注格栅

    符号函数画图

    显函数

      fplot(@(x) sin(x))      %中间不能有逗号分隔符

      隐函数

        fimplicit(@(x,y) x.^2 - y.^2 - 1)

        参数方程

          xt = @(t) cos(3*t);
          yt = @(t) sin(2*t);
          fplot(xt,yt,'g-.')

          极坐标函数

            theta=0:0.01:2*pi;%玫瑰线
            rho=2*sin(4*theta);
            polar(theta,rho)


            theta=0:0.01:6*pi;%阿基米德螺线
            rho=theta;
            polar(theta,rho)


            分段函数

              fplot(@(x) exp(x),[-3 0],'b','Linewidth',2)
              hold on
              fplot(@(x) cos(x),[0 3],'b')
              hold off
              grid on




              文章转载自Hello 帅帅,如果涉嫌侵权,请发送邮件至:contact@modb.pro进行举报,并提供相关证据,一经查实,墨天轮将立刻删除相关内容。

              评论