The Math Forum

Search All of the Math Forum:

Views expressed in these public forums are not endorsed by NCTM or The Math Forum.

Math Forum » Discussions » Software » comp.soft-sys.matlab

Notice: We are no longer accepting new posts, but the forums will continue to be readable.

Topic: Burgers Equation 1D, getting out of bounds error
Replies: 2   Last Post: Oct 18, 2013 2:35 AM

Advanced Search

Back to Topic List Back to Topic List Jump to Tree View Jump to Tree View   Messages: [ Previous | Next ]

Posts: 1,717
Registered: 11/8/10
Re: Burgers Equation 1D, getting out of bounds error
Posted: Oct 18, 2013 2:35 AM
  Click to see the message monospaced in plain text Plain Text   Click to reply to this topic Reply

"Jeetendra" wrote in message <l3omd2$bg2$>...
> 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:stepx-1
> u(n+1,j) = u(n,j) + new_c*(u(n,j+1) + u(n,j-1));
> Error at above line syats u(2,2) is out of bounds
> Please help to solve the above problem guys

Best wishes

Point your RSS reader here for a feed of the latest messages in this topic.

[Privacy Policy] [Terms of Use]

© The Math Forum at NCTM 1994-2018. All Rights Reserved.