Extract data from cell array

I have a Y array (46x1 cell). I want extract four cells (3,4,5 and 9). Each cell is composed 1x728. How I can extract the data from the cells. Thanks

 Respuesta aceptada

Azzi Abdelmalek
Azzi Abdelmalek el 30 de En. de 2014
Editada: Azzi Abdelmalek el 30 de En. de 2014

3 votos

Look at this example
y={rand(1,3) rand(1,3) rand(1,3) rand(1,3) rand(1,3)}
y([2 3])
You can have
cell2mat(y([2 3]))
or
cell2mat(y([2 3])')
For your case:
y([3 4 5 9])

4 comentarios

Bruno
Bruno el 30 de En. de 2014
Thanks for your help, I want extract data (3,4,5 and 9) from the cells and concatenate and plot. Thanks
The answer is above:
out=cell2mat(y([3 4 5 9]))
plot(out)
Ted
Ted el 30 de Oct. de 2019
If each cell contains a 2D matrix and the size of matrices are different, is there an easy way to re-format the values in the cell array into a 1D mat-array?
I guess the hard way will be to reshape the matrix within each cell into a 1D array and then, do cell2mat to concatenate them together.
I am wondering whether there is an easier way to do?
Moussa Bendjedia
Moussa Bendjedia el 27 de En. de 2023
Merci Mr Azzi Abdelmalek from Moussa of Sétif

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Data Type Conversion en Centro de ayuda y File Exchange.

Etiquetas

Preguntada:

el 30 de En. de 2014

Comentada:

el 27 de En. de 2023

Community Treasure Hunt

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

Start Hunting!

Translated by