How can i determine the analytical expression of the derived funtion "df(x)/dx" ?

조회 수: 3 (최근 30일)
How can i determine the analytical expression of the derived funtion "df(x)/dx"?
x=linspace (0:40)
L=3;
sol(1)=2;
psi=1;
f (x) = @(x) cos ( (sol(1)/L) *x)- cosh( (sol(1)/L) *x)+ psi *( sin( (sol(1)/L) *x)- sinh( (sol(1))

채택된 답변

Star Strider
Star Strider 2017년 1월 23일
Use the Symbolic Math Toolbox:
syms x
L=sym(3);
sol(1)=sym(2);
psi=sym(1);
f (x) = cos ( (sol(1)/L) *x)- cosh( (sol(1)/L) *x)+ psi *( sin( (sol(1)/L) *x)- sinh( (sol(1))));
df_dx = diff(f,x)
df_dx_fcn = matlabFunction(df_dx)
df_dx(x) =
(2*cos((2*x)/3))/3 - (2*sin((2*x)/3))/3 - (2*sinh((2*x)/3))/3
df_dx_fcn = @(x) cos(x.*(2.0./3.0)).*(2.0./3.0)-sin(x.*(2.0./3.0)).*(2.0./3.0)-sinh(x.*(2.0./3.0)).*(2.0./3.0)
  댓글 수: 2
Mallouli Marwa
Mallouli Marwa 2017년 1월 23일
If i want to comput the derived function in a point y=40 "df_dy(40)"
I obtain this error
Error using mupadmex
Error in MuPAD command: Index exceeds matrix dimensions.
Star Strider
Star Strider 2017년 1월 23일
I am not certain how you called the function, that is named ‘df_dx’, not ‘df_dy’. You can always rename it in the derivation and assignment, but you have to use the function name that exists. (I do not know if you used double quotes in your code. The double quotes (") are not valid MATLAB syntax.)
Depending on what you want, one of these will work:
y = 40;
SymOutput = df_dx(y)
SymOutput = vpa(df_dx(y))
NumOutput = df_dx_fcn(y)
SymOutput =
(2*cos(80/3))/3 - (2*sin(80/3))/3 - (2*sinh(80/3))/3
SymOutput =
-127076407709.60347598489525821488
NumOutput =
-127.0764e+009

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

추가 답변 (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