Effacer les filtres
Effacer les filtres

Info

Cette question est clôturée. Rouvrir pour modifier ou répondre.

what is the problem?

1 vue (au cours des 30 derniers jours)
fatemeh
fatemeh le 30 Déc 2013
Clôturé : MATLAB Answer Bot le 20 Août 2021
i have a loop that every time insert a vector in one row of a matrix but when i assign it i give this error massage :Index exceeds matrix dimensions. this is my code for assigning :
ps{psize,pcol}=cl{1,pcol};
that psize is 500 and pcol is 15
  1 commentaire
Image Analyst
Image Analyst le 30 Déc 2013
Please give the entire error message, that means ALL the red text, not just some of it. I want to know if it's failing at the very last, lower right element of each, in other words
ps{500,15} = cl{1,15};
or if you're trying to assign some other elements, like cl{2,42} or something. The error message should say how many elements there are in the arrays.

Réponses (1)

Azzi Abdelmalek
Azzi Abdelmalek le 30 Déc 2013
Check the sizes of ps and cl, and check if they are not less than pcol and psize
  2 commentaires
fatemeh
fatemeh le 30 Déc 2013
ps=cell(500,15); cl=cell(1,15); what is the problem?
Walter Roberson
Walter Roberson le 30 Déc 2013
At the MATLAB command line, give the command
dbstop if error
and run the program. When it stops, examine
size(cl)
pcol
I suspect you will see cl being smaller than you expect.
Question: why not use
ps(psize, pcol) = cl(1, pcol);
That would be less internal work. This will not make a difference to the array index error you are getting, but it is generally safer.

Cette question est clôturée.

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by