在2D矢量场之间插值,或3D空间中的2D矢量

时间:2013-11-24 02:21:40

标签: matlab vector interpolation matlab-figure linear-interpolation

我的程序创建2D矢量图,用于在3D空间中对风数据进行建模。我想知道如何在这些2D工作表之间进行插值。 X和Y值不会变化,因为它们对应于保持静态的纬度/经度值。矢量的W分量设置为0,只留下矢量的U / V分量在Z范围内插值,Z范围对应于两个2D矢量图之间的Z距离。

我已经阅读了interp3,但我不确定它是否适用于我正在尝试做的事情。如果你能对此有所帮助,我会非常感激,谢谢。

注意:我删除了一个与我之前提出的问题类似的问题,因为我认为我的问题过于复杂,从而使其他人有可能帮助回答这个问题。

感谢您的帮助,如果我能提供更多信息,请与我们联系!enter image description here

1 个答案:

答案 0 :(得分:1)

这是我的代码,可以在两张Z张之间插入任意数量的不同电台。我相信它可以被重写为包含interp1()函数中的所有Z表。希望这能让你朝着正确的方向前进。

zLevels = 5;   %number of interpolated points between z50 and z75
nStation = 100;     %number of (lat,long) pairs to interpolate
for i = 1:nStation %for nStation different (lat, long) pairs generate interp. values
        % generate zQuery points between z50 and z75 for each station
        zQuery = ((1:zLevels)/zLevels)*range([z50mb_vec(i) z75mb_vec(i)]) + z75mb_vec(i);
        % use interp1 to interpolate about the Z axis for U component
        U(i,1:zLevels) = interp1([z50mb_vec(i) z75mb_vec(i)],[UwindVec50mb(i) UwindVec75mb(i)],zQuery);
        % and for V component
        V(i,1:zLevels) = interp1([z50mb_vec(i) z75mb_vec(i)],[VwindVec50mb(i) VwindVec75mb(i)],zQuery);
end

% defining some color codes for each zLevel, otherwise the plot is a mess
% of colors
colorcode = ['r' 'g' 'b' 'm' 'c' 'r' 'g' 'b' 'm' 'c' 'r'];
for j = 1:nStation
    for i = 1:zLevels
    quiver3(lat_value(j), long_value(j), zQuery(i), U(j,i), V(j,i), 0, colorcode(i));
    hold on;
    end
end

生成的图(z50数据为蓝绿色,z75为红色,否则为内插图): Plot from the above code

相关问题