Index exceeds - for loop
1 visualización (últimos 30 días)
Mostrar comentarios más antiguos
ReHa
el 30 de Oct. de 2019
Respondida: ReHa
el 30 de Oct. de 2019
Hi, where is the Problem ("index exceeds matrix dimensions")?
With the "for loop" I want to calculate from Line 1 to Line 20
And the Calculation is from value 1 to value 100 each line.
What can I do, to fix the problem?
Many Thanks!!!
2 comentarios
Respuesta aceptada
Turlough Hughes
el 30 de Oct. de 2019
The problem is you are specifying indices that dont exist in val. val is a column vector of 10201x1 values, i.e. 10201 rows and 1 column.
When you write val(i,1:100) matlab looks for row i and columns 1 to 100 of val, but there is only one column in your matrix val, hence your index exceeds your matrix dimensions.
3 comentarios
Turlough Hughes
el 30 de Oct. de 2019
I would need to know more about what you are doing. You could convert your 10201 elements to a 101 by 101 array if you wanted...
val_array=reshape(val,[101 101]);
This takes the first 101 elements in column 1, the next 101 in column 2 and so on to column 101, or do you want to populate the new matrix row by row?
val_array=[reshape(val,[101 101])]';
However you will run into the same error as before on line 72 then. I suspect the overall issue lies further up in your code where you generated val.
Más respuestas (1)
Ver también
Categorías
Más información sobre Matrix Indexing en Help Center y File Exchange.
Productos
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!