function ConvertNCtoGRB(longitude,latitude,u_mean,v_mean)

template_fname = 'GribFiles/gfs20140527213506197.nc'

ncdisp(template_fname)

ncid = netcdf.open(template_fname,'WRITE');

lon_id = netcdf.inqVarID(ncid,'lon');
lon = netcdf.getVar(ncid,lon_id);
lat_id = netcdf.inqVarID(ncid,'lat');
lat = netcdf.getVar(ncid,lat_id);
u_id = netcdf.inqVarID(ncid,'var33');
u = netcdf.getVar(ncid,u_id);
v_id = netcdf.inqVarID(ncid,'var34');
v = netcdf.getVar(ncid,v_id);


%Modify template variables.
[XX,YY] = meshgrid(longitude,latitude);
[X,Y] = meshgrid(lon,lat);
u_interp = interp2(XX,YY,u_mean',X,Y);
v_interp = interp2(XX,YY,v_mean',X,Y);

u(:,:,1,1) = u_interp;
u(:,:,1,2) = u_interp;
v(:,:,1,1) = v_interp;
v(:,:,1,2) = v_interp;

%Write new values to file
netcdf.putVar(ncid,u_id,u);
netcdf.putVar(ncid,v_id,v);


netcdf.close(ncid);


