How to find the derivative of y with respect to x (hard code derivative equation into the m-file, do not use symbolic toolbox)
10 次查看(过去 30 天)
显示 更早的评论
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.
0 个评论
采纳的回答
Geoff Hayes
2020-5-13
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)?
更多回答(0 个)
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!