cell to matrix in matlab

4 visualizaciones (últimos 30 días)
Shy
Shy el 19 de En. de 2021
Respondida: dpb el 19 de En. de 2021
Hi Guys!
I have a cell with a dimension 1 by 2, e.g. X is 1 by 2 cell. Inside this cell, the first column is 3000 by 2 double matrix and the second column is 3000 by 2 double matrix as well. Both first and second columns represent different data labels. In other words, the first column is the X_even data in x and y coordinates (with size 3000 by 2), and the second column is the X_odd data in x and y coordinates (with size 3000 by 2). Now, if I convert this cell into matrix then I will get a matrix with 3000 by 4 dimension size. But What I need is to access this cell such that I get a dimension of 3000 by 2, where the first column is 3000 by 2 size and the second column ins 3000 by 2 size as well. In other words, I need something like X=[X_even Xodd] such that the size is 3000 by 2 size. Can you please help me in this? Many thanks in advance.
  1 comentario
KALYAN ACHARJYA
KALYAN ACHARJYA el 19 de En. de 2021
"X=[X_even Xodd] such that the size is 3000 by 2 size"
What will be the extra elements?
First Cell Element=3000 by 2
2nd Cell Element=3000 by 2

Iniciar sesión para comentar.

Respuestas (1)

dpb
dpb el 19 de En. de 2021
>> X=[{[[2:2:10].' rand(5,1)]},{[[1:2:10].' rand(5,1)]}]
X =
1×2 cell array
{5×2 double} {5×2 double}
>> [X{1}(:,1) X{2}(:,1)]
ans =
2.00 1.00
4.00 3.00
6.00 5.00
8.00 7.00
10.00 9.00
>>

Categorías

Más información sobre Numeric Types 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