0

I tired a simple MATLAB programming. u(j,i) is a Matrix in this case. But the code resulted in the following error.

Problem1 : Subscript indices must either be real positive integers or logicals.

Error in Problem1 (line 73) u(j,i)= (psi(j,i+1)-psi(j,i-1))*0.25;

Kindly help to solve this.

Ramesh
  • 5
  • 2
  • 2
    are you sure `i-1` is always positive ? – Dimitri Mockelyn Jan 08 '15 at 16:22
  • I'm sorry. Now I understood my mistake. i has an initial value '1'. – Ramesh Jan 08 '15 at 16:41
  • possible duplicate of [Subscript indices must either be real positive integers or logicals, generic solution](http://stackoverflow.com/questions/20054047/subscript-indices-must-either-be-real-positive-integers-or-logicals-generic-sol) – nkjt Jan 08 '15 at 16:57

1 Answers1

0

I'd be willing to bet that the FOR-loop you wrapped around the statement in question runs i from 1 to whatever, which would cause you to try to calculate psi(j,2)-psi(j,0), which MATLAB is telling you is illegal.

John R. Strohm
  • 7,547
  • 2
  • 28
  • 33