Dear sir/madam,
I have a function y=f(x). I need to differentiate this function and find the value of the differentiation(slope) at a given point (x1,y1). How could I do this in matlab? Looking forward to hearing from you soon.
Thanking you, BSD

 채택된 답변

Andrei Bobrov
Andrei Bobrov 2011년 9월 6일

0 개 추천

variant 1 use Symbolic Math Toolbox e.g.: your function f(x) = x^3+x^2*2+1
syms x
y = x^3+x^2*2+1;
df = matlabFunction(diff(y))
df =
@(x)x.*4.0+x.^2.*3.0
>> point = df(5)
point =
95
>>
variant 2 use interpolation
x = linspace(-5,5,12);
y = x.^3+x.^2*2+1;
fpp = interp1(x,y,'pchip','pp')
dfpp = fnder(fpp)
df = @(x)fnval(dfpp,x)
point = df(5)

추가 답변 (4개)

Grzegorz Knor
Grzegorz Knor 2011년 9월 6일

0 개 추천

doc diff

댓글 수: 1

bsd
bsd 2011년 9월 6일
diff() function performs only the differentiation.
After differentiating I also need the value at a given point (x1,y1).
BSD

댓글을 달려면 로그인하십시오.

Walter Roberson
Walter Roberson 2011년 9월 6일

0 개 추천

subs() in the particular point values after doing the diff() .
If you need the value in the form of a double precision number instead of a symbolic number, then use double() on the result of the subs()
Jakub Rysanek
Jakub Rysanek 2016년 10월 4일

0 개 추천

If you do not have access to Symbolic Math Toolbox, you may want to use one of my recent FileExchange submissions:
Francis Kamage
Francis Kamage 2021년 5월 16일

0 개 추천

f(x)=x^2-3*x+1

댓글 수: 1

Walter Roberson
Walter Roberson 2021년 5월 16일
This does not appear to be an answer to the question that was asked?

댓글을 달려면 로그인하십시오.

카테고리

도움말 센터 및 File Exchange에서 Spline Postprocessing에 대해 자세히 알아보기

질문:

bsd
2011년 9월 6일

댓글:

2021년 5월 16일

Community Treasure Hunt

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

Start Hunting!

Translated by