cell to matrix in matlab

2 ビュー (過去 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 Center および File ExchangeNumeric Types についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by