Trouble taking the differential of a function

조회 수: 1 (최근 30일)
Raymond Elliott
Raymond Elliott 2021년 2월 23일
답변: Star Strider 2021년 2월 23일
I have the following code:
func =@(x) (((w_0*L)/(3*(pi^4)*E*I))*48*(L^3)*cos((pi*x)/(2*L))-48*(L^3)+(3*(pi^3)*L*(x^2))-((pi^3)*(x^3)));
dfunc = diff(func);
However, whenever I try to fun the code I get the following error, "Check for missing argument or incorrect argument data type in call to function 'diff'." What am I missing here?

답변 (1개)

Star Strider
Star Strider 2021년 2월 23일
What am I missing here?
Most likely, using the Symbolic Math Toolbox.
Try this:
syms E I L w_0 x
func(x) = (((w_0*L)/(3*(pi^4)*E*I))*48*(L^3)*cos((pi*x)/(2*L))-48*(L^3)+(3*(pi^3)*L*(x^2))-((pi^3)*(x^3)));
dfunc = matlabFunction(simplify(diff(func,x), 500));
Note that ‘dfunc’ is now an anonymous function that can be used in numeric calculations outside of the Symbolic Math Toolbox.

카테고리

Help CenterFile Exchange에서 Calculus에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by