why do I get "Array indices must be positive integers or logical values"
Show older comments
D = diabetesdata;
Dm = mean (D);
Dm = 3.8451 120.8945 69.1055 20.5365 79.7995 31.9926 0.4719 33.2409 0.3490
Dsm = D - Dm
Dsm =
0.1549 20.1055 4.8945 -20.5365 -79.7995 -4.3926 -0.2279 6.7591 -0.3490
3.1549 73.1055 -1.1055 7.4635 -79.7995 3.9074 0.2731 7.7591 0.6510
4.1549 60.1055 -1.1055 15.4635 415.2005 -1.8926 0.1431 26.7591 0.6510
-2.8451 7.1055 28.8945 20.4635 -21.7995 0.0074 0.8491 -0.2409 0.6510
4.1549 -11.8945 6.8945 18.4635 34.2005 -4.0926 0.1681 -2.2409 0.6510
1.1549 18.1055 10.8945 14.4635 80.2005 -0.3926 -0.1109 -8.2409 0.6510
-0.8451 -9.8945 -7.1055 -20.5365 -79.7995 -9.3926 -0.3299 -12.2409 -0.3490
5.1549 31.1055 8.8945 13.4635 91.2005 2.2074 0.4211 -0.2409 0.6510
3.1549 57.1055 14.8945 -20.5365 -79.7995 7.9074 -0.1409 7.7591 0.6510
-2.8451 9.1055 0.8945 -7.5365 25.2005 -6.0926 0.0001 -11.2409 -0.3490
-2.8451 -25.8945 4.8945 0.4635 -6.7995 -6.0926 0.2011 2.7591 -0.3490
.....
Dstd = std(D)
Dstd = 3.3696 31.9726 19.3558 15.9522 115.2440 7.8842 0.3313 11.7602 0.4770
Dnorm = Dsm./Dstd(D)
Array indices must be positive integers or logical values.
why am i getting this when its always worked before?
Accepted Answer
More Answers (2)
Walter Roberson
on 1 Jan 2023
Edited: Walter Roberson
on 1 Jan 2023
0 votes
Dstd(D) is requesting to index the vector Dstd by the array D
Remember MATLAB has absolutely no implied multiplication.
The only implied operations that I can think of at the moment are:
- the name of a function that is not in quotes or comments, and is not proceeded by @ or ? and is not followed by (, is treated as an implicit call to the function as if () had been coded after the name
- inside [] and {} then space is horizontal concatenation
- inside [] and {} then end of line is vertical concatenation
- in the symbolic toolbox, inside piecewise() calls, A RELATION B RELATION C is sometimes treated as A RELATION B & B RELATION C
Image Analyst
on 1 Jan 2023
0 votes
To learn about this frequently asked question, see the FAQ:
Categories
Find more on BeagleBone Black in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!