switch column of table
이전 댓글 표시
If you have a table called A. And this table has three columns. How can you replace column three with column two?
댓글 수: 6
A = [1 2 3; 2 3 4; 3 5 6]
A =
1 2 3
2 3 4
3 5 6
A(:,3)=A(:,2)
A =
1 2 2
2 3 3
3 5 5
Eliah, I have noticed you have asked a few questions, however have never selected an answer as accepted. This would be helpful for the community as it makes helpful solutions stand out, which could then help other people who are facing the similar issues.
Walter Roberson
2018년 5월 24일
The above will not work exactly as written for a table() object. However you can use
A{:,3} = A{:,2};
Eliah Verbeemen
2018년 5월 25일
Walter Roberson
2018년 5월 25일
Are you sure that you are using a table() object and not a cell array or numeric array? And are you sure that your table object has three columns already?
Eliah Verbeemen
2018년 5월 25일
Walter Roberson
2018년 5월 25일
Please do not close questions that have an Answer.
채택된 답변
추가 답변 (0개)
카테고리
도움말 센터 및 File Exchange에서 Tables에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!