Info

This question is closed. Reopen it to edit or answer.

Subscript indices must either be real positive integers or logicals. Error

1 view (last 30 days)
So I am trying to write some code where I basically loaded in a file:
n=[0:1:1000];
x=file (with data);
y(n)= x(n)-x(n-3)
Matrix: size of x: 2000X1 size of n: 1X2000
I receive that error when I try to run the program. The file name data has the data listed like [1 [1.1 [1.4 [1.5 [1.8]
I am stuck on how I would rid of the error

Answers (1)

Star Strider
Star Strider on 12 Sep 2014
The problem is here:
n=[0:1:1000];
and here:
x(n-3)
Zero is not a positive integer, and any value of (n < 4) will also not work.
Possible solution:
  1. Define n=[4:1:1000]; and
  2. Define x(1:3) outside your (implied) n-loop

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!