Square shape initial condition in MATLAB

50 Views Asked by At

I am analyzing $1$D convection equation in MATLAB using Finite Difference method I would like to start the concentration $C(x,t)$ with a square pulse, and see how this square moves in space and time. Here is my Initial condition in the code

% Initial Condition for i = 1:m if (x(i) >= 0) && (x(i) <=L) C(i,1) = 1; elseif (x(i) > 0.5) && (x(i) <= L) C(i,1) = x(i); end end