Convert to fixed values and replace N/A with zero?
Show older comments
How do I convert this data to fixed values and replace N/A with zero?
6 Comments
Rik
on 6 Jul 2022
What exactly do you mean by 'fixed values'?
dpb
on 6 Jul 2022
What happened to the previous Q? you raised? You haven't accepted/commented on our efforts there, yet...
Adeline War
on 9 Jul 2022
Adeline War
on 9 Jul 2022
Accepted Answer
More Answers (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 Comments
Adeline War
on 9 Jul 2022
dpb
on 9 Jul 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
on 6 Jul 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);
Categories
Find more on Descriptive Statistics in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!


