Defining a symbolic function using the "diff" command

조회 수: 1 (최근 30일)
Ahmed
Ahmed 2013년 10월 10일
댓글: Ahmed 2013년 10월 10일
I have a function, say
Function=@ (x) x^2
I want to differentiate this function using the Diff command:
diff(Function,x,1)
and then save the output derivative function as a new function called FunctionDerv
so it will be the same as saying:
FunctionDerv= @ (x) 2x

채택된 답변

Walter Roberson
Walter Roberson 2013년 10월 10일
Function=@ (x) x^2 would be an anonymous function, not a symbolic function. None the less, you could use
syms x
sym_Function = Function(x);
sym_FunctionDerv = diff(sym_Function, x);
FunctionDerv = matlabFunction(sym_FunctionDerv);
  댓글 수: 1
Ahmed
Ahmed 2013년 10월 10일
Thank you for the quick response. Very helpful.

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Symbolic Math Toolbox에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by