how to do differentiation?

36 visualizaciones (últimos 30 días)
bsd
bsd el 6 de Sept. de 2011
Comentada: Walter Roberson el 16 de Mayo de 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

Respuesta aceptada

Andrei Bobrov
Andrei Bobrov el 6 de Sept. de 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)

Más respuestas (4)

Grzegorz Knor
Grzegorz Knor el 6 de Sept. de 2011
doc diff
  1 comentario
bsd
bsd el 6 de Sept. de 2011
diff() function performs only the differentiation.
After differentiating I also need the value at a given point (x1,y1).
BSD

Iniciar sesión para comentar.


Walter Roberson
Walter Roberson el 6 de Sept. de 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()

Jakub Rysanek
Jakub Rysanek el 4 de Oct. de 2016
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 el 16 de Mayo de 2021
f(x)=x^2-3*x+1
  1 comentario
Walter Roberson
Walter Roberson el 16 de Mayo de 2021
This does not appear to be an answer to the question that was asked?

Iniciar sesión para comentar.

Categorías

Más información sobre Spline Postprocessing en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by