"Index in position 1 is invalid. Array indices must be positive integers or logical values."
2 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
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 Commenti
Rik
il 7 Feb 2019
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
il 7 Feb 2019
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.
Risposte (1)
Preethi
il 8 Feb 2019
Initialize variable i with 1, before using it
i=1;
2 Commenti
Rik
il 8 Feb 2019
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.
Vedere anche
Categorie
Scopri di più su Matrix Indexing in Help Center e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!