alternative of inline function

7 次查看(过去 30 天)
How can i use anonymous function instead of inline?
For example, I introduced a function f=@(x) x^2-2x.
Now, I want to, derivative f(x) and store it in function g(x). and find g(a) where a is a constant ie a=5.

采纳的回答

Stephen23
Stephen23 2024-5-15
编辑:Stephen23 2024-5-15
If you want a derivative, why are you using a function handle? Using symbolic toolbox would be simpler:
syms x
f = x^2-2*x
f = 
g = diff(f)
g = 
subs(g,x,5)
ans = 
8

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Function Creation 的更多信息

产品


版本

R2023a

Community Treasure Hunt

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

Start Hunting!

Translated by