필터 지우기
필터 지우기

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);

채택된 답변

David Hill
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 CenterFile Exchange에서 Networks에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by