arrayfun num2cell structure

1 次查看(过去 30 天)
Trader
Trader 2012-4-10
I'd like to take my structure 'r' and convert each child into cell matrix with the goal of horzcat everything into on cell array.
r =
bar_count: [256x1 double]
date: [256x1 double]
time: [256x1 double]
position: [256x1 double]
After converting date and time to datestrs I'd like to
full_data = horzcat(bar_count, date, time, position)
how can I convert bar_count and position to num2cell with arrayfun()? I have several other arrays in my structure that I have to convert as well.
Thanks

回答(1 个)

Sean de Wolski
Sean de Wolski 2012-4-10
Something like:
x.a = num2cell(pi*ones(4,1));
x.b = {'hello'; 'world';'Tuesday';'coffee'};
x.c = num2cell((1:4).')
y = struct2cell(x); %first to cell then concatenate
y = horzcat(y{:})
?

类别

Help CenterFile Exchange 中查找有关 Data Type Conversion 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by