Borrar filtros
Borrar filtros

How to populate a cell array from another cell array?

7 visualizaciones (últimos 30 días)
Camilo Jurado Paez
Camilo Jurado Paez el 8 de Mzo. de 2021
Comentada: James Tursa el 10 de Mzo. de 2021
I want to populate a cell array called "labels". "Labels" should contain 4 labels for each measurement, so If I'm not wrong the cell array will be 1x4
The cell array where the info is from is called "m_test" which is a 23x117 cell. In order to populate "labels" is just needed the first row and take the first 4 data (starting at the second column), then the other 4 and so on
Some of you have any idea in how to do that?
Thank you so much

Respuesta aceptada

James Tursa
James Tursa el 8 de Mzo. de 2021
It is not clear what elements you need extracted. But you can use regular indexing with cell arrays. E.g.,
result = m_test(1,2:5)
would pick off the elements in the first row and columns 2 through 5. Etc.
  2 comentarios
Camilo Jurado Paez
Camilo Jurado Paez el 8 de Mzo. de 2021
Thank you. Do you know how to do it repeatedly? like in a loop. Because I need to do exactly that but then I'll need to pick off in the first row elements from columns 6 through 9, then 10 through 13, and so on until 114 through 117.
Appreciate your help and time
James Tursa
James Tursa el 10 de Mzo. de 2021
for k=2:4:size(m_test,2)
result = m_test(1,k:k+3);
% code that uses result goes here
end

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Matrix Indexing en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by