Table: Overwrite column value with condition

4 vues (au cours des 30 derniers jours)
Nycholas Maia
Nycholas Maia le 9 Jan 2019
Commenté : Nycholas Maia le 9 Jan 2019
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?

Réponse acceptée

Stephen23
Stephen23 le 9 Jan 2019
Modifié(e) : Stephen23 le 9 Jan 2019
This might work:
myTable.a(myTable.a < 3) = 0;
  1 commentaire
Nycholas Maia
Nycholas Maia le 9 Jan 2019
excellent! thanks Stephen!

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur Tables dans Help Center et File Exchange

Produits


Version

R2018b

Community Treasure Hunt

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

Start Hunting!

Translated by