How to write the difference quotient in matlab?

4 ビュー (過去 30 日間)
John Smith
John Smith 2017 年 11 月 8 日
編集済み: per isakson 2017 年 11 月 8 日
Hey guys, I have a question regarding writing the difference quotient. I want to write the difference quotient for a function as well as the original function. I'll give an example of what I am talking about. lets say:
x = linspace(-2*pi,2*pi)
h = .01
f(x) = sin(x).^2 + 4*x
the difference quotient is (f(x+h)-f(x))/h
I want to graph x,f(x) and x,(f(x+h)-f(x))/h
plot(x,f(x))
hold on
I get lost here. How would I go about writing how to difference quotient with it?

回答 (1 件)

Kaushik Lakshminarasimhan
Kaushik Lakshminarasimhan 2017 年 11 月 8 日
編集済み: Kaushik Lakshminarasimhan 2017 年 11 月 8 日
x = linspace(-2*pi,2*pi); h = .01;
hold on;
plot(x,sin(x).^2 + 4*x);
plot(x,((sin(x+h).^2 + 4*(x+h)) - (sin(x).^2 + 4*x))/h);

カテゴリ

Help Center および File ExchangeDesign of Experiments (DOE) についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by