find cannot read all values in .mat file
Mostra commenti meno recenti
I have a .mat file with about 12000 data, and 6 columns. this file consist of longitude and latitude and the corresponding altitude. My prob is that i use 'find' to get the row of the corresponding altitude from the input of longitude and latitude that I specified. I am sure that the input value i provided is there inside the .mat file. When using find I received the answer for 14 inputs but when the inputs are 34 and 87, find cannot find the corresponding longitude and altitude. It returns the row(r) as empty. Why is that? here is a snipet of my command. lo(longitude) and la (latitude) is the input specified by me.
long=wr1(:,1)/1000; %deg
lat=wr1(:,3)/1000; %deg
alt=wr1(:,6)*0.1; %meter
lo=(linspace(-5.2,8,34))';
la=(linspace(49,42.4,34))';
latlong=[lat,long,alt];
z=[];
for dd=1:34
la2=la(dd);
lo2=lo(dd);
[r,c,v]=find(latlong(:,1)== la2 & latlong(:,2)==lo2);
Z_Alt=alt(r);
z=[z;Z_Alt];
end
For 87 inputs this command returns only 15 outputs for altitude. Is my coding bad? i tried changing to other computers to see if the problem persist, and yes it is still there. I am using Matlab 2012a. thank you.
Risposta accettata
Più risposte (2)
Thorsten
il 17 Dic 2014
If you change the number of intermediate values in your linspace function you probably get some values that are not contained in your .dat file.
For example, if your dat file contain longitudes 1, 2, 3, ..., 10 (just for the case of simplicity), you will find corresponding values if you use
lo = linspace(1,10,10)
ans =
1 2 3 4 5 6 7 8 9 10
But for
lo = linspace(1,10,12)
ans =
1.0000 1.8182 2.6364 3.4545 4.2727 5.0909 5.9091 6.7273 7.5455 8.3636 9.1818 10.0000
you will find corresponding rows only for 1 and 10.
1 Commento
Mastura
il 17 Dic 2014
Categorie
Scopri di più su Resizing and Reshaping Matrices in Centro assistenza e File Exchange
Prodotti
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!