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