How to remove column from matlab table?

조회 수: 1,089 (최근 30일)
Clarisha Nijman
Clarisha Nijman 2018년 11월 6일
편집: Sivabalan Selvarajan 2019년 8월 3일
Dear all,
Given table: TJClean =
Xn_2 Xn_3 Xn_4 Prob1 Prob2 Prob3
____ ____ ____ _______ _______ _______
2 3 4 0.5 0.5 0.25
2 3 4 0.5 0.66667 0.33333
3 2 4 0.25 0.5 0.125
3 2 4 0.25 0.66667 0.16667
3 4 2 0.25 0.5 0.125
3 4 2 0.25 0.66667 0.16667
1 2 3 0.66667 0.5 0.33333
1 2 3 0.66667 0.5 0.33333
1 2 3 0.66667 0.33333 0.22222
2 3 4 0.33333 0.5 0.16667
2 3 4 0.33333 0.5 0.16667
2 3 4 0.33333 0.33333 0.11111
I am trying to remove a column from a matlab table(not a matrix) with the next codes:
%remove one for the last column TJNew= removevars(TJClean,5); TJNew= removevars(TJClean,'Prob2'); TJNew= removevars(TJClean,TJClean.Prob2);
but I am getting this error: Undefined function or variable 'removevars'.
What am I doing wrong? Can somebody give me a suggestion?
Thank you in advance!

채택된 답변

madhan ravi
madhan ravi 2018년 11월 6일
편집: madhan ravi 2018년 11월 6일
Try:
TJNew= removevars(TJClean,{'Prob2'});
If it doesn’t work still tell which version of matlab you are using
I suspect it’s available only from 2018a
So you can do
TJClean.Prob2=[] %this will remove the specified column
  댓글 수: 1
Cody Brant Watson
Cody Brant Watson 2019년 6월 7일
Correc! removevars is only available for 2018a and beyond.

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

추가 답변 (2개)

Cody Brant Watson
Cody Brant Watson 2019년 6월 7일
편집: madhan ravi 2019년 6월 7일
What about ...
TJClean(:,5) = []

Sivabalan Selvarajan
Sivabalan Selvarajan 2019년 8월 3일
편집: Sivabalan Selvarajan 2019년 8월 3일
You can use
TJClean( : , end-1 ) = [ ] ;

카테고리

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

Community Treasure Hunt

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

Start Hunting!

Translated by