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

12 views (last 30 days)
雅晶
雅晶 on 19 Dec 2022
Commented: COVAO on 23 Apr 2023
meshgrid 形式の 2 次元グリッド データの内挿で用いられる「interp2」において、
ドキュメンテーションでは、クエリ点「Xq、Yq」は実数のスカラーとして指定できるとあります。
そこで質問なのですが、具体的には「interp2」を使用する際、どのような場合にクエリ点を実数のスカラーとして指定するのか例を交えて説明いただけると助かります。
よろしくお願いいたします。
  1 Comment
COVAO
COVAO on 23 Apr 2023
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);

Sign in to comment.

Answers (0)

Categories

Find more on 内挿 in Help Center and File Exchange

Products


Release

R2022b

Community Treasure Hunt

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

Start Hunting!