Effacer les filtres
Effacer les filtres

Assign a "double-column" to a "cell-coloumn"

2 vues (au cours des 30 derniers jours)
alphabetacharly
alphabetacharly le 18 Juin 2018
Commenté : alphabetacharly le 9 Juil 2018
I imported some data into a (time-) table. Because of an error-message when receiving the data, few columns are cells with 'error...' as entry in the top row and '' in all other rows, while all other columns contain only doubles. I wrote some code to detect these few "error-columns" and I would like to replace them by a column full of NaNs. However, it is not possible to simply replace the column since the original column is type cell and the new one is type double and conversion from cell to double is not possible.
I hope one can understand what my Problem is and I am deeply grateful for every help.

Réponse acceptée

Greg
Greg le 19 Juin 2018
You can replace one entire column with NaN very simply:
tableVariable.VarWithErrors = NaN(height(tableVariable),1);
To do multiple variables, put the above in a loop. There might be a one-liner solution, but I'm not seeing it right now.
If you are trying to do partial columns, let me know and I'll draw up an example for that (it's a little more involved).
  1 commentaire
alphabetacharly
alphabetacharly le 9 Juil 2018
Thanks Greg. You're absolutely right. I didn't use the table.var accessing method because I didn't know that one can use numbers instead of the varnames (which I actually not know), too. For example:
a=[1, 4, 5]
table.(a)=...
And
table{:,a}=...
doesn't change the whole column.

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur Numeric Types dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by