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에서 Data Type Conversion에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!



