0

を使用して 2 次元補間を行っていinterp2ます。一部のデータ値では、次元の 1 つが既知の値のベクトルによって定義された範囲外であるため、interp2 コマンドは NaN を返します。

interp1コマンドで外挿することが可能です。しかし、これを行う方法はありinterp2ますか?

ありがとう

interp2 コマンドを使用しているコードは次のとおりです。

function [Cla] = AirfoilLiftCurveSlope(obj,AFdata,Rc,M)

% Input:
% AFdata: Airfoil coordinates.
% Rc: Local Reynolds number.
% M: Mach number for Prandtle Glauert compressibility correction.

% Output: 
% Cla: 2 dimensional lift curve slopea applicable to linear region of lift polar.

load('ESDU84026a.mat');

xi = size(AFdata);

if mod(xi(1,1),2) == 0
    %number is even
    AFupper = flipud(AFdata(1:(xi(1,1)/2),:));
    AFlower = AFdata(((xi(1,1)/2)+1):end,:);
else
    %number is odd
    AFupper = flipud(AFdata(1:floor((xi(1,1)/2)),:));
    AFlower = AFdata((floor(xi(1,1)/2)+1):end,:);
end


t_c = Airfoil.calculateThickness(AFdata(:,2));

Y90 = ((interp1(AFupper(:,1),AFupper(:,2),0.9,'linear')) - (interp1(AFlower(:,1),AFlower(:,2),0.9,'linear')))*100;

Y99 = ((interp1(AFupper(:,1),AFupper(:,2),0.99,'linear')) - (interp1(AFlower(:,1),AFlower(:,2),0.99,'linear')))*100;

Phi_TE = (2 * atan( ( (Y90/2) - (Y99/2) )/9))*180/pi;                       % Degrees
Tan_Phi_Te = ( (Y90/2) - (Y99/2) )/9;

Cla_corr = interp2(Tan_Phi,Rc_cla,cla_ratio,Tan_Phi_Te,Rc,'linear');

beta =sqrt((1-M^2));                                                        % Prandtle Glauert correction
Cla_theory = 2*pi + 4.7*t_c*(1+0.00375 * Phi_TE);                           % per rad 
Cla = (1.05/beta) * Cla_corr * Cla_theory;                                  % per rad

if isnan(Cla) == 1 %|| Cla > 2*pi
    Cla = 2*pi;
end

end
4

2 に答える 2

5

はい、docsinterp2に従って範囲外の意味のある値を返すには2つの方法があります。

  1. 'spline'内挿法を使用します。オプション #2 とは異なり、これは実際にはスプラインの境界条件に基づいてデータを推定します。
  2. 最終extrapvalパラメータを指定します。この定数はNaN、他のすべての補間方法の代わりに返されます。

残念ながら、「グリッド上の最近傍」などを指定する方法はないようです。範囲外の要素が端に近い場合は、おそらく入力配列を拡張できます。たとえば、次のようにします。

x = [x(1, 1), x(1, :), x(1, end); ...
     x(:, 1), x, x(:, end); ...
     x(end, 1), x(end, :), x(end, end)]
于 2016-01-28T15:13:43.000 に答える