How to find the derivative of y with respect to x (hard code derivative equation into the m-file, do not use symbolic toolbox)

9 visualizaciones (últimos 30 días)
My teacher has given me a task which is to plot the derivative of cost against x. Before I can plot the graph, I would need some way to find the gradient at each point in my graph. I am not allowed to use symbolic function and was told to hard code the derivative equation. Does anyone have any idea how to tackle this problem or perhaps provide me with a sample code? Thanks.
This is my code for plotting the graph of cost against x.
I have no idea how to start to find the gradient for all my x points on the curve.

Respuesta aceptada

Geoff Hayes
Geoff Hayes el 13 de Mayo de 2020
Jacky - if your cost equation is (with x the variable and D and L are constants)
f(x) = (2.5*10^6)*sqrt(D^2 + x^2) + (2.0*10^6)*(L - x);
then can't you just apply the chain rule to determine the derivative of f(x)?

Más respuestas (0)

Categorías

Más información sobre 2-D and 3-D Plots 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