Convert to fixed values and replace N/A with zero?
Afficher commentaires plus anciens
How do I convert this data to fixed values and replace N/A with zero?
6 commentaires
Rik
le 6 Juil 2022
What exactly do you mean by 'fixed values'?
dpb
le 6 Juil 2022
What happened to the previous Q? you raised? You haven't accepted/commented on our efforts there, yet...
Adeline War
le 9 Juil 2022
Adeline War
le 9 Juil 2022
Réponse acceptée
Plus de réponses (2)
Perhaps the strrep function does what you need.
data=readlines('https://www.mathworks.com/matlabcentral/answers/uploaded_files/1057030/micro.txt');
data=data(1:30);
data=strrep(data,'N/A',' 0')
2 commentaires
Adeline War
le 9 Juil 2022
dpb
le 9 Juil 2022
Read the data file as numeric to begin with and you won't need to.
But, we just solved that problem in the other topic -- "split" if there were some real reason (hard to imagine what it would be) to read as text.
You can always write the numeric data back out in text files; there's no sense in making working with numeric data in memory more difficult than needs be.
dpb
le 6 Juil 2022
- Brute force...
data=readtable('micro.txt');
data.value(isnan(data.value))=0;
2. Use builtin paramters on input...
data=readtable('micro.txt',"EmptyValue",0);
Catégories
En savoir plus sur Descriptive Statistics dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!



