How do you do a derivative with a certain value?
8 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
My initial equation is f(x) = (3*x^5)-(x^3)+(2*x^2)+4 and when I derive that, I get f'(x)=15*x^4 - 3*x^2 + 4*x. How do I evaluate f'(x) when x = 1.7?
So far I have done this:
clear all, close all
syms x f = (3*x^5)-(x^3)+(2*x^2)+4; diff(f)
This gives me the derivative, but how do I find the value of f'(x) when I have a value for x?
1 commentaire
Réponse acceptée
Geoff Hayes
le 24 Oct 2014
syms x
f = (3*x^5)-(x^3)+(2*x^2)+4;
df = diff(f);
result = double(subs(df,1.7));
Plus de réponses (1)
John D'Errico
le 24 Oct 2014
help subs
3 commentaires
John D'Errico
le 2 Déc 2022
That was not the question, to solve an ODE, or even work with one. The explicit question was asked as how to evaluate a function that you have differentiated. subs will do that.
But your question is simple to answer. Say your ODE is something easy:
y' = t^2 +2
Now evaluate the right hand side is easy.
syms y(t)
RHS = t^2 + 2;
Now you want to evaluate the right hand side for some value. Say, at t==1. You can use subs here
subs(RHS,t,1)
or you can converty the relation into a MATLAB function, as:
RHSfun = matlabFunction(RHS)
RHSfun(1)
Voir également
Catégories
En savoir plus sur Symbolic Math Toolbox dans Help Center et File Exchange
Produits
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!