convert cell to array

39 次查看(过去 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.

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Cell Arrays 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by