How to solve this equation for Laplace transform with matlab?

10 Kommentare

What do you mean by 'solving'? Is it a surface? What are those equations?
This equation is the sea floor displacement function. I want to solve this equation to obtain the free surface elevation. So, we need to transform this equation by using Fourier-Laplace transform with matlab. Please....
Did you try to build those surface/equations? Can you show your attempts?
Where is the problem?
clear
clc
syms eta0 L v t x y k k1 k2 s h w
% eta0 = 2 ;
% L = 100 ;
% W = 100 ;
% v = 0.14 ;
% h = 2;
% g = 0.0098;
% t = 5.95;
T1 = (eta0*v*t)/(2*L)*(1-cos(pi/50*x)).*(1-cos(pi/100*(y+150))) ;
T2 = (eta0*v*t)/L*(1-cos(pi/50*x)) ;
T3 = (eta0*v*t)/(2*L)*(1-cos(pi/50*x)).*(1-cos(pi/100*(y-150))) ;
T=T1+T2+T3;
%Laplace transform of 'T'.
Lap = laplace(T)
%Double Fourier transform of 'Lap' for 'x' and 'y'.
eta_1 = fourier(Lap,x,k1)
eta_ = fourier(eta_1,y,k2)
%Substituting 'eta_' into 'zeta_1' formula.
% w = sqrt(g*k*tanh(k*h))
zeta_1 = (eta_.*s^2)/(cosh(k*h)*(s^2+w^2))
%Inverse Laplace transform of 'zeta_1'.
zeta_ = ilaplace(zeta_1,s,t)
%Double inverse Fourier transform of 'zeta_' for 'k1' and 'k2'.
zeta1 = ifourier(zeta_,k1,x)
zeta = ifourier(zeta1,k2,y)
%For figure.
x=0;100;
y=linspace(-200,200,101)
[X,Y] = meshgrid(x,y) ;
surf(X,Y,zeta)
I can't figure.
Since you are using the symbolic toolbox anyhow, use piecewise() to define your equation. Then when you have it in piecewise form, ude rewrite() specifying the 'Heaviside' option. With the equation in heaviside form, the symbolic toolbox laplace transform functions can create appropriate expressions.
Could you please help me an example code for this problem? Please sir....
syms eta0 L v t x y k k1 k2 s h w
T1 = (eta0*v*t)/(2*L)*(1-cos(pi/50*x)).*(1-cos(pi/100*(y+150))) ;
T2 = (eta0*v*t)/L*(1-cos(pi/50*x)) ;
T3 = (eta0*v*t)/(2*L)*(1-cos(pi/50*x)).*(1-cos(pi/100*(y-150))) ;
R = @(V,L,H,X)heaviside(V-L)*heaviside(H-V)*X
T = simplify( R(x,0,100,R(y,-150,-50,T1) + R(y,-50,50,T2) + R(y,50,150,T3)) )
Now you can do laplace() on T. However, when you do so, you need to specify which variable you are transforming with respect to. Likewise when you fourier, make sure you do so with respect to the correct variable.
Also, you need to carefully examine what happens at the exact boundaries.
Thanks you so much for your kindness. When I was calculating your advice, I got a result but not figure. I want to get 3D figure. But I cannot try it. Please help me sir. How to plot for 3D?
syms eta0 L v t x y k k1 k2 s h w
eta0 = 2 ;
L = 100 ;
W = 100 ;
v = 0.14 ;
h = 2;
g = 0.0098;
t = 5.95;
T1 = (eta0*v*t)/(2*L)*(1-cos(pi/50*x)).*(1-cos(pi/100*(y+150))) ;
T2 = (eta0*v*t)/L*(1-cos(pi/50*x)) ;
T3 = (eta0*v*t)/(2*L)*(1-cos(pi/50*x)).*(1-cos(pi/100*(y-150))) ;
R = @(V,L,H,X)heaviside(V-L)*heaviside(H-V)*X
T = simplify( R(x,0,100,R(y,-150,-50,T1) + R(y,-50,50,T2) + R(y,50,150,T3)) )
Lap = laplace(T)
%Double Fourier transform of 'Lap' for 'x' and 'y'.
eta_1 = fourier(Lap,x,k1)
eta_ = fourier(eta_1,y,k2)
%Substituting 'eta_' into 'zeta_1' formula.
w = sqrt(g*k*tanh(k*h))
zeta_1 = (eta_.*s^2)/(cosh(k*h)*(s^2+w^2))
%Inverse Laplace transform of 'zeta_1'.
zeta_ = ilaplace(zeta_1,s,t)
%Double inverse Fourier transform of 'zeta_' for 'k1' and 'k2'.
zeta1 = ifourier(zeta_,k1,x)
zeta = ifourier(zeta1,k2,y)
%For figure.
x=0;100;
y=linspace(-200,200,101)
[X,Y] = meshgrid(x,y);
surf(X,Y,zeta)
Your zeta is a symbolic expression in k and y according to symvar(), but it also contains k2 inside fourier() calls.
Perhaps you should do
kvals = 0:100;
yvals = linspace(-200,200,101);
[K,Y] = meshgrid(kvals, yvals);
Zsym = subs(zeta, {k, y}, {K, Y});
Z = double(Zsym);
surf(K,Y,Z)
However in practice this does not work: after the substitution, double() is not able to resolve some of the values to numeric. I discovered that some of them can be converted to a better form by using simplify(Zsym), but that is slow.
Thank you so much sir, I want to try it. If I did not know, let me ask you.

Melden Sie sich an, um zu kommentieren.

Antworten (0)

Kategorien

Mehr zu Programming finden Sie in Hilfe-Center und File Exchange

Gefragt:

am 21 Feb. 2020

Kommentiert:

am 2 Mär. 2020

Community Treasure Hunt

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

Start Hunting!

Translated by