MATLAB Answers

Table: Overwrite column value with condition

19 views (last 30 days)
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?

  0 Comments

Sign in to comment.

Accepted Answer

Stephen Cobeldick
Stephen Cobeldick on 9 Jan 2019
Edited: Stephen Cobeldick on 9 Jan 2019
This might work:
myTable.a(myTable.a < 3) = 0;

  1 Comment

Sign in to comment.

More Answers (0)

Sign in to answer this question.

Products


Release

R2018b