empty array size is stuck on 1x3
1 visualizzazione (ultimi 30 giorni)
Mostra commenti meno recenti
%Start with an empty matrix
data=[];%Handle to open file
fileID=fopen('Track-16.gpx','r');
%Skip the first 14 lines
fscanf(fileID,'\n\n\n\n\n\n\n\n\n\n\n\n\n\n');
%Scan through until the end of file(feof). Specification low level IO.
%Result transposed and formatted into single matrix
while ~feof(fileID)
nextrow=fscanf(fileID, '%*s lat="%f" lon="%f">\n <ele>%f</ele>\n <time>2013-01-19T%f:%f:%f</time>\n');
nextrow=nextrow';
data=[data;nextrow];
end
fclose(fileID)
%Separating data file into separate vectors.
latitude=[data(1:end,1)];
longitude=[data(1:end,2)];
elevation=[data(1:end,3)];
hours=[data(1:end,4)];
minutes=[data(1:end,5)];
seconds=[data(1:end,6)];
THis is my error
Index in position 2 exceeds array bounds. Index must not exceed 3.
Error in test6 (line 19)
hours=[data(1:end,4)];
0 Commenti
Risposte (2)
per isakson
il 26 Ott 2021
Modificato: per isakson
il 26 Ott 2021
Try replace
fscanf(fileID,'\n\n\n\n\n\n\n\n\n\n\n\n\n\n');
by
for jj = 1 : 14
fgetl( fileID );
end
fscanf(fileID,'\n\n\n\n\n\n\n\n\n\n\n\n\n\n'); affects the current location of the position pointer in the specified file for blank lines only. (Test with ftell() .) Does the file starts with fourteen blank lines?
0 Commenti
Vedere anche
Categorie
Scopri di più su Matrix Indexing in Help Center e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!