"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!