Error when indexing 3D cell array: Index in position 2 exceeds array bounds
Mostrar comentarios más antiguos
EDIT: more details provided by myself in the second comment
Hi,
I have a cell array with 19 cells. Within each cell there is a matrix with 21 columns. Now I want to loop a piece of code over each of these columns within the matrices inside each of the cells.
When I run my code I get the error "Index in position 2 exceeds array bounds".
This is the code:
num_cells = size(participants);
num_columns = size(participants{i},2);
block_size = 512;
p_windows = {};
for j = 1:1:num_cells
for k = 1:1:num_columns
N = block_size*ceil(numel(participants{i},2)/block_size);
participants{i,2}(end+1:N) = NaN;
p_windows = reshape(participants{i,2},512,[]);
end
end
My goal is to take each individual column from the matrices in participants and cut them into smaller 512 element long lists. These 512 long lists are then stored in matrices (one matrix per cut-up column) and saved in a new cell array (p_windows).
I dont understand which line this is referring to as it doesn't mention which indexing. Does anyone know how I could fix this?
Thank you!
2 comentarios
the cyclist
el 22 de En. de 2022
I tried to guess what the variable participants looks like, to replicate your error, but I couldn't.
Can you please upload the data (using the paperclip icon in the INSERT section of the toolbar)?
Also,
- This must not be the full code, since it references a variable i that we do not see
- The full error message will always reference the line number where the error occurs, so you have not told us that either
Please, make it easier for us to help you.
Respuesta aceptada
Más respuestas (0)
Categorías
Más información sobre Matrix Indexing en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!