%finds the maximum n values of a vector

function out = max3(in, num);

N=length(find(isnan(in) ==0)); %number of non-NaN entries

if num > N;
    error('Number of max values exceeds vector length or number of non NaN values')
end

A=sort(in);



out=A(N+1-num:N);
