Info
Diese Frage ist geschlossen. Öffnen Sie sie erneut, um sie zu bearbeiten oder zu beantworten.
ascci reading fscanf help.
1 Ansicht (letzte 30 Tage)
Ältere Kommentare anzeigen
Hi there, I have a ascii data file that i need to remove the first 12 rows (they contain metadata) so i do like this:
fid=fopen('madeira_3.asc')
for i=1:12;
fgetl(fid);
end
(i don't need the metadata saved so i just dump into ans)
now, i usually do a fcanf to read the rest and it works, but this time my data has decimals and is space delimited. here is how the data looks like:
" -17,313 33,371 -3971
-17,304 33,371 -3968
-17,296 33,371 -3964
-17,288 33,371 -3962
-17,279 33,371 -3959
-17,271 33,371 -3955 "
I used the code below to try to organize it in a 3 column matrix but i get stuck in the -17 when it finds the comma it stops, only if i read it as a string it works fine, but i dont want it as a string.
grid_2=fscanf(fid,'%f');
Could you please help me out. Tks in advanced. Rod.
0 Kommentare
Antworten (2)
Walter Roberson
am 19 Okt. 2012
grid_2=fscanf(fid,'%f,%f%f,%f%f,%f');
Then put the columns together, such as column1 * 1000 + sign(column1) .* column2
Alternately, read as strings, delete the commas, and parse the result as numbers.
0 Kommentare
Diese Frage ist geschlossen.
Siehe auch
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!