"Index in position 1 is invalid. Array indices must be positive integers or logical values."
조회 수: 2 (최근 30일)
이전 댓글 표시
I get the entitled error when ever i run the code below
nu=sum((i-(n+1)/2).*Y(i,:)
for the equation
and also the same error for
de=sqrt(n^3*(sum(Y(i,:)-mean(Y(i,:)))^.2))
for the equation
where first is the numerator and second is the denominator of D, "test for normality was given by D’Agostino"
full code
y1=[51 27 37 42 27 43 41 38 36 26 29]';
y2=[36 20 22 36 18 32 22 21 23 31 20]';
y3=[50 26 41 32 33 43 36 31 27 31 25]';
y4=[35 17 37 34 14 35 25 20 25 32 26]';
y5=[42 27 30 27 29 40 38 16 28 36 25]';
Y=[y1 y2 y3 y4 y5]
Y=sort(Y)
[n p]=size(Y)
nu=sum((i-(n+1)/2).*Y(i,:))
de=sqrt(n^3*(sum(Y(i,:)-mean(Y(i,:)))^.2))
D=nu./de
YY=sqrt(n)*(D-inv(2*sqrt(pi)))/0.02998598
댓글 수: 2
Rik
2019년 2월 7일
Without the full code you are using it is difficult to provide a working solution. Try to make a MWE so we can run your code without any other dependencies and can reproduce your issue.
Currently it is not possible to tell if you are shadowing the sum function with a variable named sum, or if your i variable is not properly defined.
Rik
2019년 2월 7일
You didn't define i yourself, so now Matlab treats it as the imaginary unit. I don't have a clue what you're trying to do, but it seems you should read the documentation for the symbolic computation toolbox, or rewrite your expression to a normal Matlab computation.
답변 (1개)
Preethi
2019년 2월 8일
Initialize variable i with 1, before using it
i=1;
댓글 수: 2
Rik
2019년 2월 8일
Although this modification will make this code run without error, this will not return the solution for the mathematical expression. I don't understand the notation (specifically the equal sign inside the sum), but I'm sure this will not solve the problem.
참고 항목
카테고리
Help Center 및 File Exchange에서 Matrix Indexing에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!