"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