matlab 可视化(specifier)

来源:互联网 发布:学英语从零开始软件 编辑:程序博客网 时间:2024/06/03 19:51
  • grid on:加网格
  • box off(取消右边框和上边框);
  • xlim([-3, 3]) vs ylim([0, 5])

1. plot

一种精简的写法,就是:plot(x, y, 'r-s'):分别表示,颜色为red,线型为实线,形状为square(正方形)

  • 属性: ‘linewidth’, ‘color’, ‘marker’, ‘linestyle’
    • line style:
      • -:实线(默认),Solid line (default)
      • --:虚线,Dashed line
      • ::点线,Dotted line
      • -.:虚、点线,Dash-dot line
    • color:(rgb、y、w、k)
      • m:magenta;品红,洋红;
      • c:cyan;蓝绿色,青色;
    • marker:
      • o:,+:,*,x,^,v,><
      • s:square,d:diamond,p:Pentagram,五角星形;h:六线形;六角星形(雪花);
  • 设置坐标轴刻度

    set(gca, 'xtick', 0:5:365)
  • 一次画多条曲线(用不同的 marker 标示)

    plot(x, t, 'o', x, y, 'x')

2. 释例

  • softplus 函数

    f(x)=ln(1+ex)

    x = -5:.01:5;y = log(1+exp(x));plot(x, y, 'linewidth', 3, 'color', 'k');ylim([0, 5]);grid on

3. 设置 figure 的属性

  • position

    set(gcf, 'position', [100, 100, 400, 300])                    % 100, 100:表示以屏幕左下角为原点的偏移量                    % 400:宽,300:高

4. legend

legend('sin(x)','cos(x)')

常见属性:

  • (1)’Location’,’northwest’
  • (2)’Orientation’,’horizontal’
  • (3)’FontSize’,8,’FontWeight’,’bold’
0 0
原创粉丝点击