File size: 2,781 Bytes
5ab75a9 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 | function LogPremint = interp_LogPrem(LogPcum,LogPrem,LogPcumgoal)
% interp_LogPrem - Interpolate LogPrem values
%
% Syntax: LogPremint = interp_LogPrem(LogPcum,LogPrem,LogPcumgoal)
%
% =========================================================================
%
% Copyright (c) 2025 United States Government as represented by the
% Administrator of the National Aeronautics and Space Administration.
% All Rights Reserved.
%
% =========================================================================
%
% Description: Interpolate LogPrem values. Returns a Prem value
% corresponding to the desired Pcum through linear
% interpolation of Prem and corresponding Pcum values
%
% =========================================================================
%
% Input:
%
% LogPcum - Log of Pcum values [1xN]
%
% LogPrem - Log of Prem values corresponding to LogPcum values [1xN]
%
% LogPcumgoal - Desired LogPcum value for which to interpolate a
% corresponding LogPrem
% =========================================================================
%
% Output:
%
% LogPremint - Interpolated Prem value corresponding to LogPcumgoal
%
% =========================================================================
%
% Dependencies:
%
% None
%
% =========================================================================
%
% Subfunctions:
%
% None
%
% =========================================================================
%
% Initial version: Apr 2022; Latest update: Apr 2022
%
% ----------------- BEGIN CODE -----------------
if LogPcum(1) > LogPcumgoal
LogPremint = LogPrem(1);
elseif LogPcum(end) < LogPcumgoal
LogPremint = min(LogPcumgoal,LogPrem(end));
else
n1 = max(find((LogPcum <= LogPcumgoal)));
n2 = n1+1;
LogPremint = interp1(LogPcum(n1:n2),LogPrem(n1:n2), ...
LogPcumgoal,'linear','extrap');
LogPremint = min(LogPcumgoal,LogPremint);
end
return;
end
% ----------------- END OF CODE ------------------
%
% Please record any changes to the software in the change history
% shown below:
%
% ----------------- CHANGE HISTORY ------------------
% Developer | Date | Description
% ---------------------------------------------------
% D. Hall | 2022-Apr-11 | Initial version.
% =========================================================================
%
% Copyright (c) 2025 United States Government as represented by the
% Administrator of the National Aeronautics and Space Administration.
% All Rights Reserved.
%
% ========================================================================= |