close







MATLAB微分




立即點擊


假設t=[0:0.001:5];xr=sin(12.57*t);一次微分xrdot=12.57*cos(12.57*t);二次微分xrdoubledot=-158*sin(12.57*t);請問那.m的程式要怎麼寫??





>> syms t %宣告符號物件 >> f=sin(12.57*t) %給函數 f f = sin(1257/100*t) >> df=diff(f) %求一次微分 df = 1257/100*cos(1257/100*t) >> df2=diff(f,2) %求二次微分 df2 = -1580049/10000*sin(1257/100*t) 若要化成小數(選4位數) >> df=vpa(df,4) df = 12.57*cos(12.57*t) >> df2=vpa(df2,4) df2 = -158.0*sin(12.57*t) 若選6位數 改成 >> clear >> syms t >> f=sin(12.57*t) f = sin(1257/100*t) >> df=diff(f) df = 1257/100*cos(1257/100*t) >> df2=diff(f,2) df2 = -1580049/10000*sin(1257/100*t) >> df=vpa(df,6) df = 12.5700*cos(12.5700*t) >> df2=vpa(df2,6) df2 = -158.005*sin(12.5700*t) ----------------------------------- 要將 t=[0:0.001:5] 帶入 f, df, df2 求值 可以利用 >> ff=subs(f,t); >> dff=subs(df,t); >> dff2=subs(df2,t); 因為這總共有5001個數字 所以指令後面最好加上分號; 就是不要將結果顯現在螢幕上





clearall;h=0.001;t=[0:h:5];xr=12.57*t;xr'=diff(sin(x))/h,%xr的一次微分xr"=diff(xr')/h,%xr"的二次微分參考資料:me


以上文章來自奇摩知識家,如有侵犯請留言告知


https://tw.answers.yahoo.com/question/index?qid=20070331000015KK04423

AAFD2ED9159ECC62
arrow
arrow

    低價機票 發表在 痞客邦 留言(0) 人氣()