Attempted to access PriorProb(8); index out of bounds because numel(PriorProb)=7.

Error: Attempted to access PriorProb(8); index out of bounds because numel(PriorProb)=7.
What does this error mean? I got it when I put in:
W(i,1) = -0.5 * Temp * GroupMean(i,:)' + log(PriorProb(i));
I have 7 prior probability numbers that I used and this error showed up. Need help!!!

 Accepted Answer

You must prevent the index variable i from reaching a value of 8.

7 Comments

How exactly are you setting i right now? If it's a loop variable, make sure you're doing
for i=1:7,...,end
and not
for i=1:8,...,end
After this I would need to combine it with a cross validation method which dosen't utilise statistics toolbox. Would u happen to know any?
Thanks for the help! Im trying it right now and welcome other suggestions...

Sign in to comment.

More Answers (0)

Categories

Find more on Loops and Conditional Statements 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!