g_error_polyfit.m 407 Bytes
Newer Older
1
function err = g_error_polyfit(cv,lonlon,latlat,err_ll,order);
Daniel Bourgault's avatar
Daniel Bourgault committed
2

3 4
n_gcp = length(err_ll);
err   = 0;
Daniel Bourgault's avatar
Daniel Bourgault committed
5

6
for k = 1:n_gcp
Daniel Bourgault's avatar
Daniel Bourgault committed
7 8 9 10 11 12 13 14 15 16 17 18 19 20

  if order == 1
      
    efit = cv(1)*lonlon(k)+cv(2)*latlat(k)+cv(3);  
    
  elseif order == 2
      
    efit = cv(1)*lonlon(k)^2+cv(2)*latlat(k)^2+cv(3)*lonlon(k)*latlat(k)+cv(4)*lonlon(k)+cv(5)*latlat(k)+cv(6);
    
  end
  
  err = err + (efit-err_ll(k))^2;

end