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

1 次查看(过去 30 天)
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

回答(1 个)

Tom
Tom 2012-2-21
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 个评论
Tom
Tom 2012-2-21
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.

请先登录,再进行评论。

类别

Help CenterFile Exchange 中查找有关 Fourier Analysis and Filtering 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by