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!



