cell to matrix in matlab

조회 수: 1 (최근 30일)
Shy
Shy 2021년 1월 19일
답변: dpb 2021년 1월 19일
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
KALYAN ACHARJYA
KALYAN ACHARJYA 2021년 1월 19일
"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

댓글을 달려면 로그인하십시오.

답변 (1개)

dpb
dpb 2021년 1월 19일
>> 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
>>

카테고리

Help CenterFile Exchange에서 Numeric Types에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by