Cell array string formatting

9 ビュー (過去 30 日間)
Paul Richardson
Paul Richardson 2020 年 7 月 10 日
コメント済み: madhan ravi 2020 年 7 月 10 日
I have a cell array, of which the first few rows look like this:
run_configurations =
27×6 cell array
{1×1 cell} {'12:52'} {1×1 cell} {1×1 cell} {1×1 cell} {1×1 cell}
{1×1 cell} {'12:58'} {1×1 cell} {1×1 cell} {1×1 cell} {1×1 cell}
{1×1 cell} {'13:05'} {1×1 cell} {1×1 cell} {1×1 cell} {1×1 cell}
I do not know how to convert that second column so that each string is in its own cell array, so it looks like the others... can anyone please advise how to convert that column to 1x1 cell arrays please? Or advise how to create that column directly in the necessary format?
The code which creates that second column is as follows:
run_configurations(:,2) = cellstr(datestr([data{ia,time_column}],'HH:MM'))
... where ia is an index array created by "unique" and time_column is just an integer.
The time column of "data" is as follows:
data(ia,time_column)
ans =
27×1 cell array
{[7.3748e+05]}
{[7.3748e+05]}
{[7.3748e+05]}
I am very new to MATLAB just trying to get my head around the different types of arrays and how to convert between them. I have played around with various combinations of brackets and conversions but I can't seem to get it quite right.
Thank you!

採用された回答

madhan ravi
madhan ravi 2020 年 7 月 10 日
編集済み: madhan ravi 2020 年 7 月 10 日
run_configurations(:,2) = num2cell(cellstr(datestr([data{ia,time_column}],'HH:MM')))
  3 件のコメント
Paul Richardson
Paul Richardson 2020 年 7 月 10 日
編集済み: Paul Richardson 2020 年 7 月 10 日
Ah you've changed it whilst I was testing/replying!
Looks like that new answer will work too. Thanks again
madhan ravi
madhan ravi 2020 年 7 月 10 日
num2cell(..., 2)

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeData Type Conversion についてさらに検索

製品


リリース

R2019a

Community Treasure Hunt

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

Start Hunting!

Translated by