You are an expert in writing code in many different languages. Your goal is to perform code completion for the following code, keeping in mind the rest of the code and the file meta data.
    Metadata details:
    filename: find_besthist.m
    path of file: ./repos/matlab_owc/matlab_codes
    
    the code of the file until where you have to start completion: 
function [ index ] = find_besthist( grid_lat, grid_long, grid_dates, grid_Z, LAT, LONG, DATES, Z, latitude_large, latitude_small, longitude_large, longitude_small, phi_large, phi_small, age, age_large, map_pv_use, max_casts )

%
% Find ln_max_casts unique historical points that are most strongly correlated with the float profile.
%
% Rewritten Dec 2006 to only use lat, lon, date and water depth as input
    
function [ index ] = find_besthist( grid_lat, grid_long, grid_dates, grid_Z, LAT, LONG, DATES, Z, latitude_large, latitude_small, longitude_large, longitude_small, phi_large, phi_small, age, age_large, map_pv_use, max_casts )

%
% Find ln_max_casts unique historical points that are most strongly correlated with the float profile.
%
% Rewritten Dec 2006 to only use lat, lon, date and water depth as input
% and to return index into station list.
%
% Annie Wong, June 2010.
% Breck Owens, December 2006.
%
% Cecile Cabanes, June 2013
% track "change config 129" : add age_large when computing correlation_large



% avoid having PV=0, because if PV=0, ellipse>1, and no historical points will be selected ---

PV_float = (2*7.292*10^-5.*sin(LAT.*pi/180))./Z;
PV_hist = (2*7.292*10^-5.*sin(grid_lat.*pi/180))./grid_Z;

if(PV_float==0)PV_float=1*10^-5;end