Merge all rows in a cell into one row

74 ビュー (過去 30 日間)
BN
BN 2020 年 2 月 10 日
編集済み: Turlough Hughes 2020 年 2 月 10 日
Hey all, Here is my 40 x 32 cell.
I want to merge all 40 rows into one row. So in the output, I would like to have a 1 x 1280 cell. 1280 is 40 * 32.
Capture.JPG
I searched and tried to use
result = num2cell(NewC2LatLon,2);
But it gave me totally wrong answers.
Thank you all.

採用された回答

Turlough Hughes
Turlough Hughes 2020 年 2 月 10 日
編集済み: Turlough Hughes 2020 年 2 月 10 日
Similar to numeric arrays writting NewC2LatLon(:) returns all the all elements of the array in a single column. However, I think what you want is to take the second row and add it to the right of the first, and so on. You can do that as follows:
NewC2LatLon = NewC2LatLon.';
NewC2LatLon = NewC2LatLon(:).';
  2 件のコメント
Turlough Hughes
Turlough Hughes 2020 年 2 月 10 日
編集済み: Turlough Hughes 2020 年 2 月 10 日
For example:
>> a = reshape(1:9,3,3) % Sample array
a =
1 4 7
2 5 8
3 6 9
>> a = a.'
a =
1 2 3
4 5 6
7 8 9
>> a = a(:).'
a =
1 4 7 2 5 8 3 6 9
The result is you get the rows placed beside each other.
BN
BN 2020 年 2 月 10 日
Thank you.

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeMultidimensional Arrays についてさらに検索

タグ

製品


リリース

R2018b

Community Treasure Hunt

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

Start Hunting!

Translated by