フィルターのクリア

Plot a graph and its derivatives

50 ビュー (過去 30 日間)
Kosmas-Damianos Giannakos
Kosmas-Damianos Giannakos 2016 年 3 月 18 日
回答済み: Ced 2016 年 3 月 18 日
syms x y; f=@(x)sin(x.^2).*cos(x); dy=diff(f(x)) df=@(x)subs(dy); diff(f(x),2); dy2=diff(f(x),2); df2=@(x)subs(dy2); x=linspace(-pi,pi,25); plot(f(x),x)
I am trying to plot in the graph together with the original function the first and the second derivative , with the plot command any help on how to approach this step?

回答 (1 件)

Ced
Ced 2016 年 3 月 18 日
You basically have it. The plot function format is "plot(x,y)" though, meaning x coordinates and y coordinates, so your version is probably the mirrored image of what you want. You can just append the rest.
plot(x,f(x),x,df(x),x,df2(x))
xlim(x([ 1 end ]))
grid on
xlabel('x')
ylabel('y')
legend('f(x)','df(x)','ddf(x)')

カテゴリ

Help Center および File ExchangeLine Plots についてさらに検索

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by