日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 >

台湾国立大学郭彦甫Matlab教程笔记(9) basic plotting

發布時間:2025/4/5 22 豆豆
生活随笔 收集整理的這篇文章主要介紹了 台湾国立大学郭彦甫Matlab教程笔记(9) basic plotting 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

臺灣國立大學郭彥甫Matlab教程筆記(9)
today:
1.basic plotting
2.graphical objects properties

basics

matlab has a powerful plotting engine that can generate a wide variety of plots

plot from ‘‘data’’

1.matlab does not understand functions f(t)=sin(2pit)
2.strategies:
generate the numetic values
data point

function

plot()

  • plot(x,y) plots each vector pairs(x , y)
  • matlab會 refresh ,把之前的圖給清掉,如果 想保留,用 指令 hold on

    下面是sin和cos的圖像

    plot(cos(0:pi/20:2*pi)); hold onplot(sin(0:pi/20:2*pi));

    plot style

    plot(x,y,‘str’)plots each vector pairs(x,y ) using the format defined in str (check linespec)

    畫 marker
    如果想要sin函數 用圈圈,顯示紅色 需要這樣添加

    plot(sin(0:pi/20:2*pi),'or');

    o表示circle圈圈,r表示red紅色
    如果想要cos函數用叉叉,綠色。則如下:xg

    plot(cos(0:pi/20:2*pi),'xg');

    legend()函數

    add legend to graph 添加圖標 legend(‘L1’,‘L2’,‘L3’…)
    position adjustment

    畫圖:

    x=0:0.5:4*pi; y=sin(x); h=cos(x); w=1./(1+exp(-x)); g=(1/(2*pi*2)^0.5).*exp((-1.*(x-2*pi).^2)./(2*2^2)); plot(x,y,'bd-',x,h,'gp:',x,w,'ro-',x,g,'c^-');

    分析:4個函數,用一個plot畫出來。
    'bd-'表示:blue diomond solid line 意思是藍色的,鉆石(棱形)的,實線
    'gp:'表示: green five-point star dotted line 意思是 綠色的五角星表示的點線
    'ro-'表示: red circle solid line 紅色的圓圈的實線
    'c^-'表示: cyan up triangle solid line 青色,上三角,實線
    沒有legend的時候 ,

    現在為了區分這四個函數,需要添加legend圖標

    legend('sin(x)','cos(x)','Sigmoid','Causs function');

    效果圖:

    title() and lable()

    title()
    xlable()
    ylable()
    zlable()

    例程:

    x=0:0.1:2*pi; y1=sin(x); y2=exp(-x);%兩個函數 plot(x,y1,'--*',x,y2,':o');%畫圖 xlabel('t=0 to 2\pi');%x軸 ylabel('values of sin(x) and e^{-x}');%y軸 title('Function plots if sin(x) and e^{-x}');%標題 legend('sin(x)','e^{-x}');%曲線圖標

    效果:
    注意:反斜杠\ +pi 這樣顯示的話 直接是Π ,在字符串里面

    text() and annotation()

    問題:積分符號怎么顯示呢?
    text with mathematical expression using Latex
    這個積分符號是用text()函數寫的 ,text函數前兩個參數是坐標,畫在哪兒。第三個參數是 積分 這個變量str,后面是一個插值
    slash 反斜杠 \int 是∫符號
    積分的表示:

    str=' $$ \int_ {0}^{2} x^2\sin(x) dx$$';

    前后都有兩個$$,然后是積分符號,\int_ 然后是上下限 {0}^{2},之后就是一個被積函數 x^2\sin(x) dx
    箭頭使用annotation 畫的 ,arrow, X的位置變化 ,Y的位置變化

    代碼:

    x=linspace(0,3); y=x.^2.*sin(x);plot(x,y); line([2,2],[0,2^2*sin(2)]); str=' $$ \int_ {0}^{2} x^2\sin(x) dx$$'; text(0.25,2.5,str,'Interpreter','latex'); annotation('arrow','x',[0.32,0.5],'y',[0.6,0.4]);

    效果圖;積分的顯示

    作業題:

    我的練習代碼:

    t=1:0.01:2; f=t.*t; g=sin(2*pi*t); %畫圖 plot(t,f,'k-',t,g,'or'); %坐標軸和標題 xlabel('Time (ms)'); ylabel('f(t)'); title('Mini Assignment #1'); %標注函數 legend('t^2','sin(2\pit)');

    效果圖:

    [總結】
    本文記錄了基本的繪圖知識。主要是text()函數顯示積分,還有一些畫線的style風格。

    總結

    以上是生活随笔為你收集整理的台湾国立大学郭彦甫Matlab教程笔记(9) basic plotting的全部內容,希望文章能夠幫你解決所遇到的問題。

    如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。