www.gusucode.com > matlab 案例源码 matlab代码程序 > matlab/ConvertCellArrayofStructurestoArrayExample.m

    %% Convert Cell Array of Structures to Array  

%% 
% Convert structures in a cell array into one structure array. The structures
% must have the same fields. 
s1.a = [1 2 3 4];
s1.b = 'Good';
s2.a = [5 6; 7 8];
s2.b = 'Morning';
c = {s1,s2};
d = cell2mat(c)  

%% 
% Display the first field of structure |d(1)|. 
d(1).a  

%% 
% Display the second field of |d(2)|. 
d(2).b