Append rows to an empty table

조회 수: 50 (최근 30일)
Deepa Maheshvare
Deepa Maheshvare 2019년 11월 13일
편집: Ajay Kumar 2019년 11월 13일
I am trying to append rows to an empty table
t = table
for i = 1:3
column1 = rand(2,1)
column2 = rand(2,1)
tempt = table(column1, column2, 'VariableNames',{'c1','c2'});
t = join(t,tempt)
end
This is not working
Cannot find a common table variable to use as a key variable.
Any suggestions on how to append rows to empty table?

채택된 답변

Ajay Kumar
Ajay Kumar 2019년 11월 13일
편집: Ajay Kumar 2019년 11월 13일
t = table;
for i = 1:3
column1 = rand(2,1);
column2 = rand(2,1);
tempt = table(column1, column2, 'VariableNames',{'c1','c2'});
t = [t;tempt];
end
If you know the length of the final t, consider preallocating t in line 1 using zeros or ones to improve performance.

추가 답변 (0개)

카테고리

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

태그

제품


릴리스

R2019b

Community Treasure Hunt

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

Start Hunting!

Translated by