function step = X_1way(t,y) global c dx % finite difference: -c(dy/dx) % - shifted values to left & right % % yL y yR % --------+--+--+------ % xL x xR yR = [y(2:end) ; y(1)]; yL = [y(end) ; y(1:end-1)]; % 1st-order upwind diff step = -c*(y - yL)/dx; % 2nd-order centered diff %step = -c*(yR - yL)/dx/2; % 1st-order downwind diff %step = -c*(yR - y)/dx; return