How do I convert a double into a cell array?

Hi, I am attempting to convert a double called 'instantaneous_frequency_v' into a cell array. 'instantaneous_frequency_v' is currently a double with the dimensions 30 x 1 (see attached) How do I convert this into a 1 x 30 cell array? Thanks in advance.

 採用された回答

Cris LaPierre
Cris LaPierre 2021 年 1 月 15 日

0 投票

You can use num2cell.
Use the transpose operator to convert a 30x1 to a 1x30.
a=(1:5)'
a = 5×1
1 2 3 4 5
b=num2cell(a')
b = 1x5 cell array
{[1]} {[2]} {[3]} {[4]} {[5]}

2 件のコメント

Cai Chin
Cai Chin 2021 年 1 月 15 日
Hi, thank you for your answer. Apologies, I asked the incorrect question. How would I instead convert a 30 x 1 double into a 1 x 1 cell array containing a 1 x 30 double?
Cris LaPierre
Cris LaPierre 2021 年 1 月 15 日
編集済み: Cris LaPierre 2021 年 1 月 15 日
a=(1:5)'
a = 5×1
1 2 3 4 5
b={a'}
b = 1x1 cell array
{1×5 double}

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

その他の回答 (0 件)

カテゴリ

ヘルプ センター および File ExchangeCell Arrays についてさらに検索

タグ

質問済み:

2021 年 1 月 15 日

編集済み:

2021 年 1 月 15 日

Community Treasure Hunt

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

Start Hunting!

Translated by