alternative of inline function

3 Ansichten (letzte 30 Tage)
MD MASNUN HASNINE
MD MASNUN HASNINE am 15 Mai 2024
Bearbeitet: Stephen23 am 15 Mai 2024
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.

Akzeptierte Antwort

Stephen23
Stephen23 am 15 Mai 2024
Bearbeitet: Stephen23 am 15 Mai 2024
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

Weitere Antworten (0)

Kategorien

Mehr zu Function Creation finden Sie in Help Center und File Exchange

Produkte


Version

R2023a

Community Treasure Hunt

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

Start Hunting!

Translated by