alternative of inline function

조회 수: 17 (최근 30일)
MD MASNUN HASNINE
MD MASNUN HASNINE 2024년 5월 15일
편집: Stephen23 2024년 5월 15일
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