Averaging z values for xy gridded data
    8 visualizzazioni (ultimi 30 giorni)
  
       Mostra commenti meno recenti
    
I have a dataset of lat lon areas and corresponding values. This is a small sample:
   maxlat    minlat   minlon    maxlon    temp 
   60.0000   50.0000  170.0000  180.0000  -16.1680
   60.0000   50.0000  170.0000  180.0000   -8.6020
   70.0000   60.0000  170.0000  180.0000  -52.5874
   70.0000   60.0000  170.0000  180.0000  -54.0840
   70.0000   60.0000  170.0000  180.0000  -53.5014
         0  -10.0000  170.0000  180.0000   19.6848
         0  -10.0000  170.0000  180.0000   22.4549
   10.0000         0  170.0000  180.0000  -56.9327
   10.0000         0  170.0000  180.0000  -65.2633
I don't know how to average the temp values for each grid area where values of lat and lon are equal.
0 Commenti
Risposte (2)
  Shounak Shastri
      
 il 24 Feb 2020
        Hello Ara,
So the brute force implementation would be to run a search through your data and check the lat and lon values. If they are equal, then copy the temp values in a separate array. Once you have gone through the completre data, you can use mean() to find the average. This is a lenghty process though and might take some time to complete.
An easier way to do this would be to use find() to get the indices of all the values of maxlat which are same, then check if those rows are equal. 
for example,
k = find(maxlat == maxlat(1)); %Generate a vector of rows with same values of maxlat
%say k = [1, 2]
%the name of your table is "table"
isequal (table(k(1), :), table(k(2), :))% Check if all the coloums are equal
if the answer is true, then average, otherwise skip.
Good Luck!!
0 Commenti
  KSSV
      
      
 il 24 Feb 2020
        A = [60.0000   50.0000  170.0000  180.0000  -16.1680
   60.0000   50.0000  170.0000  180.0000   -8.6020
   70.0000   60.0000  170.0000  180.0000  -52.5874
   70.0000   60.0000  170.0000  180.0000  -54.0840
   70.0000   60.0000  170.0000  180.0000  -53.5014
         0  -10.0000  170.0000  180.0000   19.6848
         0  -10.0000  170.0000  180.0000   22.4549
   10.0000         0  170.0000  180.0000  -56.9327
   10.0000         0  170.0000  180.0000  -65.2633];
   temp = A(:,end) ; 
   lat = A(:,1) ; 
   [c,ia,ib] = unique(lat) ; 
   temp_avg = zeros(length(c),1) ;
  for i = 1:length(c)
    temp_avg(i) = mean(temp(ib==i)) ; 
  end
0 Commenti
Vedere anche
Categorie
				Scopri di più su Geographic Plots 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!


