u =
integrate for long equation
이전 댓글 표시
can someone help me check my code , because i get the answer is not i expected. thanks
the orignal equation is:

code
syms p c A H T k z d x w t c2 v u pi
% Define symbolic expressions for v and u
v_expr = ((pi*H)/T)*(cosh(k*(z+d))/sinh(k*d))*cos(k*x-w*t);
u_expr = ((2*pi^2*H)/T^2)*(cosh(k*(z+d))/sinh(k*d))*sin(k*x-w*t);
% Define f using the symbolic expressions for v and u
f = p*(1+c)*A*u_expr + (1/2)*p*c2*v_expr*abs(v_expr);
% Compute the integral of f with respect to z
F = int(f,z)
댓글 수: 7
Dyuman Joshi
2024년 4월 10일
The equations are not clear (atleast to me), as there are symbols missing.
Please post the equations in text format or attach a picture.
Also, specify what the expected answer/output is.
Liam
2024년 4월 10일
In your expression for V the first term does not match the equation.
v_expr = (pi*H/T)*(cosh(k*(z+d))/sinh(k*d))*sin(k*x-w*t)
GUILU
2024년 4월 10일
Liam
2024년 4월 10일
Add pi to the list of symbolic variables, it will clean up the output lots.
syms p c A H T k z d x w t c2 v u pi
GUILU
2024년 4월 10일
Aquatris
2024년 4월 10일
This is missing the D term:
f = p*(1+c)*A*u_expr + (1/2)*p*c2*v_expr*abs(v_expr);
So should be
f = p*(1+c)*A*u_expr + (1/2)*p*c2*v_expr*D*abs(v_expr);
답변 (1개)
Hi @GUILU
You can DIVIDE the integrand and then CONQUER it. Once you've done that, you can validate the result by comparing it with your hand-calculated solution.
syms k z d mu1 mu2 mu3 mu4 nu1 nu2 nu3 nu4
assume(k > 0 & nu1 > 0 & nu2 > 0 & cosh(k*(z + d)) > 0)
%% Define symbolic expressions for v and u
% mu1 = (2*pi^2*H)/T^2; % constant
% mu2 = sin(k*x-w*t); % constant
% mu3 = p*(1 + c)*A; % constant
u = mu1*(cosh(k*(z + d))/sinh(k*d))*mu2
% nu1 = (pi*H)/T; % constant
% nu2 = cos(k*x-w*t); % constant
% nu3 = (1/2)*p*c2; % constant
v = nu1*(cosh(k*(z + d))/sinh(k*d))*nu2
% Define f using the symbolic expressions for v and u
f = mu3*u + nu3*v*abs(v)
% Compute the integral of f with respect to z
F = int(f, z)
F = simplify(F, 'steps', 100)
댓글 수: 2
GUILU
2024년 4월 13일
You are welcome, @GUILU. The key is to make MATLAB easy to interpret the "integrand" so that it can perform the integral efficiently. In your case,
such that
.
such that If you find the solution helpful, please consider clicking 'Accept' ✔ on the answer and voting 👍 for it. Your support is greatly appreciated!
카테고리
도움말 센터 및 File Exchange에서 Calculus에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!


