How do i use textscan for quality control?
정보
이 질문은 마감되었습니다. 편집하거나 답변을 올리려면 질문을 다시 여십시오.
이전 댓글 표시
I have a file with this data. YY/MM/DD HH -Level- Atm.Prs -Tw- 09/06/15 00 0.0492 1019.24 25.5
I'm trying to do some quality control to the data, so i'd like to read it, add an extra column to add flags, check for spikes, fix NaNs and a few more procedures.
I tried to use fopen and then textscan, but it says that Param/value pairs must come in pairs. What am I doing wrong? this is the code:
fid = fopen('090615.m43', 'r');
T = textscan(fid, 'ReadVariableNames', false, 'format', '%s%d%f%f%f', 'HeaderLines',1 , 'Delimiter', 'tab');
댓글 수: 0
답변 (1개)
Star Strider
2015년 5월 9일
It’s probably choking on 'tab' and some other small problems. Use '\t' instead:
T = textscan(fid, '%s%d%f%f%f', 'HeaderLines',1 , 'Delimiter', '\t');
I removed 'ReadVariableNames', false, because that is not in my R2015a documentation for textscan. If it’s in your version, keep them in.
With these changes, it should work (although I don’t have your file to check it).
댓글 수: 3
Nicole Scerri
2015년 5월 9일
Walter Roberson
2015년 5월 9일
rowhasnan = isnan(T{2}) | isnan(T{2}) | isnan(T{4}) | isnan(T{5});
T.flag(rowhasnan) = 6;
If you want to display the final table, you could use fprintf() in a loop, or if you have a new enough MATLAB version you could use the table facility
Star Strider
2015년 5월 9일
@Walter — Thank you. Away for a bit here. Life intrudes.
이 질문은 마감되었습니다.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!