"Subscript indices must either be real positive integers or logicals" Error... How to solve this!

1 view (last 30 days)
let ECd
ECd =
15.7000
33.9000
10.2000
8.4000
40.7000
37.4000
37.2000
37.8000
33.7000
31.6000
26.7000
22.9000
19.6000
6.1000
1.9000
1.5000
1.4000
1.2500
1.8000
2.3000
N = size(ECd,1);
for i = N:-1:1;
Min2(i-2)= min (ECd(i:N));
Max2(i-2)= max (ECd(i:N));
Mean2(i-2)= mean (ECd(i:N));
Median2(i-2) = median(ECd(i:N));
Std2(i-2)= std (ECd(i:N));
Q52(i-2)= prctile(ECd(i:N),[5]);
Q752(i-2) = prctile(ECd (i:N),[75]);
end
Its say im having this problem as below
??? Subscript indices must either be real positive integers or logicals.
Error in ==> VarCalculation_ASMS at 93
Min2(i-2)= min (ECd(i:N)); % Min value of ECd
I surf in the community, one of the answer is which size, which cell
I'm not sure what he meant! thanks

Answers (1)

Tom
Tom on 21 Feb 2012
the smallest value of i is 1, but you are assigning to an array by using i-2. So for the 2nd to last iteration of the loop you are trying to store in Min2(0). This doesn't exist in Matlab- the array is arranged from 1 to however many you need. This is the 'real or positive integers' part of the error.
  1 Comment
Tom
Tom on 21 Feb 2012
the which size/ which cell bit from the other question refers to the fact that you can call a variable the same name as a function. So for example, there is a function called max, which unsurprisingly is used to find the maximum value in a group of numbers. But, if you call a variable 'max', then you can no longer use the max function.
Type 'which max' into the command window, then make a variable called 'max' (e.g. max=1), and type 'which max' again, and see the difference in what comes up.

Sign in to comment.

Categories

Find more on Fourier Analysis and Filtering in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!