function [rmw, rmw_position]=rmw_at_one_height(flight_data, tgwind, xaxis,zaxis,rmw_height)

% [max_value, position] = max(flight_data(:,4));
% 
% rmw_deg=distance(flight_data(1,2),flight_data(1,3),flight_data(position,2), flight_data(position,3));
% rmw_flt=distdim(rmw_deg,'deg','m');
% x_flt=distance(flight_data(1,2)*ones(length(flight_data),1),flight_data(1,3)*ones(length(flight_data),1),flight_data(:,2), flight_data(:,3));
% x_flt=distdim(x_flt,'deg','m');

diff_resid=abs(rmw_height - zaxis);
[min_value, level] = min(diff_resid);
[max_value, rmw_position] = nanmax(tgwind(:,level));
rmw=xaxis(rmw_position)*ones(1,length(zaxis));
rmw_position=rmw_position*ones(1,length(zaxis));

% if isnan(max_value)==1
%     diff_flt=abs(xaxis - rmw_flt);
%     
%contourf(xaxis,zaxis,tgwind(:,1:length(zaxis))',25)