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

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

Melden Sie sich an, um zu kommentieren.

Antworten (0)

Kategorien

Mehr zu 内挿 finden Sie in Help Center und File Exchange

Produkte


Version

R2022b

Community Treasure Hunt

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

Start Hunting!