u =
integrate for long equation
Mostrar comentarios más antiguos
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 comentarios
Dyuman Joshi
el 10 de Abr. de 2024
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
el 10 de Abr. de 2024
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
el 10 de Abr. de 2024
Liam
el 10 de Abr. de 2024
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
el 10 de Abr. de 2024
Aquatris
el 10 de Abr. de 2024
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);
Respuestas (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 comentarios
GUILU
el 13 de Abr. de 2024
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!
Categorías
Más información sobre Calculus en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!


