how to do differentiation?
24 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
bsd
am 6 Sep. 2011
Kommentiert: Walter Roberson
am 16 Mai 2021
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
0 Kommentare
Akzeptierte Antwort
Andrei Bobrov
am 6 Sep. 2011
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)
0 Kommentare
Weitere Antworten (4)
Walter Roberson
am 6 Sep. 2011
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()
0 Kommentare
Jakub Rysanek
am 4 Okt. 2016
If you do not have access to Symbolic Math Toolbox, you may want to use one of my recent FileExchange submissions:
0 Kommentare
Siehe auch
Kategorien
Mehr zu Spline Postprocessing finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!