Table: Overwrite column value with condition

조회 수: 10 (최근 30일)
Nycholas Maia
Nycholas Maia 2019년 1월 9일
댓글: Nycholas Maia 2019년 1월 9일
I would like to overwrite all values of a specific column, but using a condition, like this:
% Dummy array values:
a = [1;2;3;4;5];
% Create a table with only 1 column 'a':
myTable = table(a);
% WRONG CODE: trying to overwrite 'a' column values
myTable = myTable(myTable.a < 3) == 0;
How could I do it?

채택된 답변

Stephen23
Stephen23 2019년 1월 9일
편집: Stephen23 2019년 1월 9일
This might work:
myTable.a(myTable.a < 3) = 0;

추가 답변 (0개)

카테고리

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

제품


릴리스

R2018b

Community Treasure Hunt

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

Start Hunting!

Translated by