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))
댓글 수: 0
채택된 답변
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
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 Center 및 File Exchange에서 Symbolic Math Toolbox에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!