필터 지우기
필터 지우기

add column in table

조회 수: 92 (최근 30일)
Luca Re
Luca Re 2023년 7월 11일
댓글: Luca Re 2023년 7월 12일
T= struct2table(G);
c=1:length(T);
c=c';
i want to add c as new column of T!

채택된 답변

Voss
Voss 2023년 7월 11일
G = struct('ones',{1 1 1 1},'twos',{2 2 2 2}); % for example
T= struct2table(G);
c=1:height(T); % use height
c=c';
T.new_column = c
T = 4×3 table
ones twos new_column ____ ____ __________ 1 2 1 1 2 2 1 2 3 1 2 4
  댓글 수: 7
Voss
Voss 2023년 7월 12일
[Is it] possible [to] move c in the first column?
Yes, see below:
G = struct('ones',{1 1 1 1},'twos',{2 2 2 2}); % for example
T= struct2table(G);
c=1:height(T); % use height
c=c';
T.new_column = c;
T = T(:,[end 1:end-1])
T = 4×3 table
new_column ones twos __________ ____ ____ 1 1 2 2 1 2 3 1 2 4 1 2
Luca Re
Luca Re 2023년 7월 12일
thank

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

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

Community Treasure Hunt

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

Start Hunting!

Translated by