Got Questions? Get Answers.
Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

Thread Subject:
Index out of bounds

Subject: Index out of bounds

From: miss

Date: 21 Apr, 2010 10:13:07

Message: 1 of 3

Hello,

I am trying to run a program CMK for large matrix and for some examples of matrix I recive
Attempted to access queue(1,1471); index out of bounds because size(queue)=[1,1470].

Error in ==> RCMK at 21
        r = queue(1,head);

qsize = size(queue,2);
    while(qsize < n)
        % mutam capatul si alegem un nod
        head = head + 1;
        r = queue(1,head);


 Thank you!

Subject: Index out of bounds

From: Sean

Date: 21 Apr, 2010 11:25:08

Message: 2 of 3

"miss " <myozotmi@yahoo.com> wrote in message <hqmj3j$q99$1@fred.mathworks.com>...
> Hello,
>
> I am trying to run a program CMK for large matrix and for some examples of matrix I recive
> Attempted to access queue(1,1471); index out of bounds because size(queue)=[1,1470].
>
> Error in ==> RCMK at 21
> r = queue(1,head);
>
> qsize = size(queue,2);
> while(qsize < n)
> % mutam capatul si alegem un nod
> head = head + 1;
> r = queue(1,head);


I think you're using the wrong concept here. qsize never changes and neither does n. That is why it isn't stopping. You've created an infinite while loop.


Either do:
for head = 1:qusize
    r = queue(1,head);
end
Or:
head = 0; %initialize
while (head < qsize)
      head = head + 1;
      r = queue(1,head);
end

Subject: Index out of bounds

From: miss

Date: 21 Apr, 2010 12:18:04

Message: 3 of 3

"Sean " <sean.dewolski@nospamplease.umit.maine.edu> wrote in message <hqmnak$8er$1@fred.mathworks.com>...
> "miss " <myozotmi@yahoo.com> wrote in message <hqmj3j$q99$1@fred.mathworks.com>...
> > Hello,
> >
> > I am trying to run a program CMK for large matrix and for some examples of matrix I recive
> > Attempted to access queue(1,1471); index out of bounds because size(queue)=[1,1470].
> >
> > Error in ==> RCMK at 21
> > r = queue(1,head);
> >
> > qsize = size(queue,2);
> > while(qsize < n)
> > % mutam capatul si alegem un nod
> > head = head + 1;
> > r = queue(1,head);
>
>
> I think you're using the wrong concept here. qsize never changes and neither does n. That is why it isn't stopping. You've created an infinite while loop.
>
>
> Either do:
> for head = 1:qusize
> r = queue(1,head);
> end
> Or:
> head = 0; %initialize
> while (head < qsize)
> head = head + 1;
> r = queue(1,head);
> end


Thank you very much!
It works!!!

Tags for this Thread

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

Contact us