필터 지우기
필터 지우기

Add columns to tables with loops

조회 수: 11 (최근 30일)
Isai Fernandez
Isai Fernandez 2020년 5월 19일
답변: Ameer Hamza 2020년 5월 19일
I want to create a first column for my table, after a loop. I tried like this:
%N(mxn)
i=1;
while i<= size(N,1)
capa(i) = fprintf('Bar #',int2str(i));
i=i+1;
end
Furthermore I used sprintf.
The result in this case of three rows, it would be:
Bar 1
Bar 2
Bar 3

채택된 답변

Ameer Hamza
Ameer Hamza 2020년 5월 19일
See this example
t = array2table(rand(3)); % example table
rows = compose('Bar %d', [1 2 3]);
rows = vertcat(rows{:});
T = [table(rows, 'VariableNames', {'labels'}) t];

추가 답변 (0개)

카테고리

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

제품


릴리스

R2020a

Community Treasure Hunt

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

Start Hunting!

Translated by