「interp2」におけるクエリ点について

11 次查看(过去 30 天)
雅晶
雅晶 2022-12-19
评论: COVAO 2023-4-23
meshgrid 形式の 2 次元グリッド データの内挿で用いられる「interp2」において、
ドキュメンテーションでは、クエリ点「Xq、Yq」は実数のスカラーとして指定できるとあります。
そこで質問なのですが、具体的には「interp2」を使用する際、どのような場合にクエリ点を実数のスカラーとして指定するのか例を交えて説明いただけると助かります。
よろしくお願いいたします。
  1 个评论
COVAO
COVAO 2023-4-23
interp2 は格子点X,YとZで表される2D ルックアップテーブルで、Xq, YqにおけるZqを補間計算します。
以下はクエリ点をプロットする例です。
% Generate grid data
x = linspace(0, 5, 10);
y = linspace(0, 5, 10);
[X, Y] = meshgrid(x, y);
Z = sin(X) + cos(Y);
% Specify the query point as a real scalar
xq = 1.3;
yq = 4.1;
% Interpolate the data using the interp2() function
Zq = interp2(X, Y, Z, xq, yq, 'linear');
% Show results
surf(X, Y, Z);
hold on;
scatter3(xq, yq, Zq, 20, 'r', 'filled');
xlabel('X');
ylabel('Y');
zlabel('Z');
s=sprintf('Interpolated value at (xq, yq) = (%.2f, %.2f) is: %.4f\n', xq, yq, Zq);
title(s);

请先登录,再进行评论。

回答(0 个)

类别

Help CenterFile Exchange 中查找有关 内挿 的更多信息

产品


版本

R2022b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!