フィルターのクリア

convert cell to array

32 ビュー (過去 30 日間)
RuiQi
RuiQi 2017 年 7 月 13 日
編集済み: Stephen23 2021 年 8 月 12 日
I have a structure sp. How can I copy the content name into an arrray ? Its supposed to be an array of numbers.
a = sp.name;
a = sp(:).name;
does not work

採用された回答

Adam
Adam 2017 年 7 月 13 日
編集済み: Adam 2017 年 7 月 13 日
names = { sp.Name }
will extract them into a single cell array
nums = cellfun( @str2double, names );
will turn them to a numeric array. Or just
cellfun( @str2double, { sp.Name } )
as a one-line command.
  1 件のコメント
Stephen23
Stephen23 2021 年 8 月 12 日
編集済み: Stephen23 2021 年 8 月 12 日
Simpler and more efficient:
str2double({sp.name })

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

その他の回答 (0 件)

カテゴリ

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

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by