フィルターのクリア

How do you do a derivative with a certain value?

12 ビュー (過去 30 日間)
Yianni
Yianni 2014 年 10 月 24 日
コメント済み: John D'Errico 2022 年 12 月 2 日
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 件のコメント
RASHID MALIK ANSARI
RASHID MALIK ANSARI 2020 年 2 月 27 日
I also have same problem

サインインしてコメントする。

採用された回答

Geoff Hayes
Geoff Hayes 2014 年 10 月 24 日
Yianni - try using subs as
syms x
f = (3*x^5)-(x^3)+(2*x^2)+4;
df = diff(f);
result = double(subs(df,1.7));
  1 件のコメント
Yianni
Yianni 2014 年 10 月 24 日
Perfect thank you!

サインインしてコメントする。

その他の回答 (1 件)

John D'Errico
John D'Errico 2014 年 10 月 24 日
help subs
  3 件のコメント
Torsten
Torsten 2022 年 12 月 2 日
編集済み: Torsten 2022 年 12 月 2 日
In this case, the derivative is the ODE expression itself.
E.g.
syms x y
dydx = x + y; % ODE is dy/dx = x + y
x0 = 1;
y0 = 2; % initial condition is y(1) = 2
dydx0 = subs(dydx,[x y],[x0 y0]) % derivative at x0 = 1 is dydx0 = x0 + y0 = 3
dydx0 = 
3
John D'Errico
John D'Errico 2022 年 12 月 2 日
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)
ans = 
3
or you can converty the relation into a MATLAB function, as:
RHSfun = matlabFunction(RHS)
RHSfun = function_handle with value:
@(t)t.^2+2.0
RHSfun(1)
ans = 3

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeSymbolic Math Toolbox についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by