Is there a way to create and preallocate for tables with a large number of variables (can all be of same type e.g. double) without having to specify each variable independently?

조회 수: 22 (최근 30일)
I want to create tables with a large number of variables (i.e. many columns of data all of type double) so using for example
sz =[1000,1000]; vartype = {'double','double',....,'double'}; T = table{'Size',sz,'VariableTypes',vartype};
is not reasonable. I assume there's an easier way to do this (i.e. without having to write 'double' thousands of times), but haven't been able to find it. Any suggestions would be appreciated.

채택된 답변

Matt J
Matt J 2018년 9월 27일
편집: Matt J 2018년 9월 27일
sz =[1000,1000];
vartype = repmat({'double'},1,sz(2)) ;
T = table('Size',sz,'VariableTypes',vartype);

추가 답변 (1개)

Matt J
Matt J 2018년 9월 27일
편집: Matt J 2018년 9월 27일
Another way,
T=array2table(rand(sz));

카테고리

Help CenterFile Exchange에서 Logical에 대해 자세히 알아보기

제품


릴리스

R2018a

Community Treasure Hunt

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

Start Hunting!

Translated by