how can I write my function in terms of code using Finite difference method (FDM) to obtain these curves at time, t=0 and time, t=2?
1 次查看(过去 30 天)
显示 更早的评论
% Initialization
Nx= 480; % x-Grid
dx= 3/480; % Step size
x(:,1)= (0:Nx-1)*dx;
f= 125.7; % Wave number
U(:,1)= -16*(x(:,1)-1/2).^2
% U(:,1) = exp(-16*(x(:,1)-1/2).^2);
U(:,1)= exp(U(:,1));
U(:,1)= U(:,1).*sin(f*x(:,1))
%U(:,1)= exp(-16*(x(:,1)-1/2).^2)%sin*(f*x(:,1))
%U(:,1)= U(:,1).*sin(f*x(:,1))
mpx= (Nx+1)/2; % Mid point of x-axis
% (Mid point of 1 to 3= 2 here)
T= 10; % Total no. of time step
f= 125.7; % Wave number
dt= 0.000625; % time-step
t(:,1)= (0:T-1)*dt;
v= 1; % wave velocity
c=v*(dt/dx); % CFL condition
s1= floor(T/f);
0 个评论
采纳的回答
David Hill
2022-1-29
x=0:.001:3;
u=@(t)exp(-16*(x-(.75*t+.5)).^2).*sin(125.7*x);
plot(x,u(0))
figure
plot(x,u(2))
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Calculus 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!