www.gusucode.com > matlab 案例源码 matlab代码程序 > matlab/TreatScalarStuctureAsArrayExample.m
%% Treat Scalar Stucture As Array % Use |'AsArray',true| to create a table from a scalar structure whose fields % have different numbers of rows. %% % Create a scalar structure, |S|, with fields |name|, |billing|, and |test|. S.name = 'John Doe'; S.billing = 127.00; S.test = [79, 75, 73; 180, 178, 177.5; 220, 210, 205]; S %% % The fields have a different number of rows. Therefore, you cannot use % |struct2table(S)|, which uses |'AsArray',false| by default. %% % Treat the scalar structure as an array and convert it to a table. T = struct2table(S,'AsArray',true) %% % |T| contains one row.