How do i use textscan for quality control?
Informazioni
Questa domanda è chiusa. Riaprila per modificarla o per rispondere.
Mostra commenti meno recenti
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');
Risposte (1)
Star Strider
il 9 Mag 2015
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 Commenti
Nicole Scerri
il 9 Mag 2015
Walter Roberson
il 9 Mag 2015
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
il 9 Mag 2015
@Walter — Thank you. Away for a bit here. Life intrudes.
Questa domanda è chiusa.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!