Hi!
I am trying to solve the problem in the text attached.
I am copying my MATLAB code to solve the Lax Wendroff scheme. I am struggling to put in the periodic boundary conditions. Maybe someone could guide?
Thanks!
% MAE 5093 Homework #5- Due November 13th, 2018
%%Problem 1
%%Code written by Saad Saleem
% % This MATLAB code solves linear convection equation
clear allclose allN=100; %No. of grid points
Tmax=1; % time period=1
alpha=1; %given
h=0.01; %given value of delX
delt=0.005;maxt=Tmax/delt; %Number of time steps
c=alpha*delt/h; %c=0.5
% Initial condition
for i=1:N+1; x(i)=(i-1)*h; u(i,1)=sin(2*pi*x(i));end% Temp at boundaries
for k=1:maxt+1; u(1,k)=u(N+1,k);endu=zeros(maxt,N);for k=1:maxt for i=1:N %Space loop
u(i,k+1) =u(i,k)-c/2*(u(i+1,k)-u(i-1,k))+(c.^2)/2*(u(i+1,k)-2*u(i,k)+u(i-1,k)); endend
Best Answer