Effacer les filtres
Effacer les filtres

importing an empty text column rather than a number column

2 vues (au cours des 30 derniers jours)
Afolabi Fashola
Afolabi Fashola le 10 Août 2020
Commenté : Afolabi Fashola le 14 Août 2020
Hello,
I have a excel spreadsheet with 12 columns that I imported into MATLAB using readtable. The issue is there are two text columns which could sometimes be empty and sometimes not. Whenever its empty and i run the code MATLAB imports the table and replaces the empty cells with NAN showing its not a text column but i want it to be replaces with single qoutes (' ') instead because it is a text column.
  2 commentaires
Stijn Haenen
Stijn Haenen le 10 Août 2020
Use the num2str command and change every NaN to ' ':
Data=num2str(Data);
Data(Data=='NaN')=' ';
Afolabi Fashola
Afolabi Fashola le 10 Août 2020
So is Data the name of the variable that stores my table?

Connectez-vous pour commenter.

Réponse acceptée

J. Alex Lee
J. Alex Lee le 11 Août 2020
Are you already using something like detectImportOptions() or spreadsheetImportOptions()? If not, look at that
And then look at setVarType().

Plus de réponses (0)

Produits

Community Treasure Hunt

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

Start Hunting!

Translated by