arrayfun num2cell structure

1 visualizzazione (ultimi 30 giorni)
Trader
Trader il 10 Apr 2012
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

Risposte (1)

Sean de Wolski
Sean de Wolski il 10 Apr 2012
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{:})
?

Categorie

Scopri di più su Data Type Conversion in Help Center e File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by