Search All of the Math Forum:
Views expressed in these public forums are not endorsed by
Drexel University or The Math Forum.


Torsten
Posts:
1,526
Registered:
11/8/10


Re: Burgers Equation 1D, getting out of bounds error
Posted:
Oct 18, 2013 2:35 AM


"Jeetendra" wrote in message <l3omd2$bg2$1@newscl01ah.mathworks.com>... > stepx=50; % Number of spatial steps > T=5; % Total time > k=0.01; % Duration of time step > stept=T/k; % Number of time steps > h=.01; % Width of each spatial > c=0.001; % Constant (Supposing the value as 0.001) > new_c = c*k/(2*h); % Courant Number > x=2*pi:h:2*pi; > u=zeros(stept,stepx);%Initialize velocity data array to zero. > % Giving Initial Condition > u=sin(4*pi*x); > u=zeros(stept,stepx) gives a matrix, u=sin(4*pi*x) gives a vector. So in the next step, you want to write a matrix element (u(2,2)) into a vector which does not work. Furthermore, you generate an x vector (x=2*pi:h:2*pi) the dimension of which does not equal stepx.
> %The below for loop calculates subsequent velocities > for n=2:k:4 > for j=2:h:stepx1 > > u(n+1,j) = u(n,j) + new_c*(u(n,j+1) + u(n,j1)); > Error at above line syats u(2,2) is out of bounds > Please help to solve the above problem guys
Best wishes Torsten.



