Convert to fixed values and replace N/A with zero?
显示 更早的评论
How do I convert this data to fixed values and replace N/A with zero?
6 个评论
Rik
2022-7-6
What exactly do you mean by 'fixed values'?
dpb
2022-7-6
What happened to the previous Q? you raised? You haven't accepted/commented on our efforts there, yet...
Adeline War
2022-7-9
Adeline War
2022-7-9
采纳的回答
更多回答(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 个评论
Adeline War
2022-7-9
dpb
2022-7-9
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
2022-7-6
- Brute force...
data=readtable('micro.txt');
data.value(isnan(data.value))=0;
2. Use builtin paramters on input...
data=readtable('micro.txt',"EmptyValue",0);
类别
在 帮助中心 和 File Exchange 中查找有关 Descriptive Statistics 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!



