Table: Overwrite column value with condition

4 visualizzazioni (ultimi 30 giorni)
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?

Risposta accettata

Stephen23
Stephen23 il 9 Gen 2019
Modificato: Stephen23 il 9 Gen 2019
This might work:
myTable.a(myTable.a < 3) = 0;

Più risposte (0)

Categorie

Scopri di più su Tables in Help Center e File Exchange

Prodotti


Release

R2018b

Community Treasure Hunt

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

Start Hunting!

Translated by