scatteredInterpolant function is providing too much noise in interpolation

9 ビュー (過去 30 日間)
Ahmad Gad
Ahmad Gad 2022 年 8 月 7 日
回答済み: Bruno Luong 2022 年 8 月 7 日
Hello there.
I have a function V = f(X,Y). Where the mesh on X,Y is non uniform and its boundaries aren't rectangular. I am trying to use scatteredinterpolant function to evaluate Vq = f(Xq, Yq), but MATLAB always provide a lot of noise in the interpolated results, and I am not able to identify the reason.
Please refer to the attached data file for the numerical values of the variables (X,Y,V,Xq,Yq). I am using the following code,
clc
clear
load('Interpolation.mat')
surf(X,Y,V)
h=gca;
xlabel ('X');ylabel ('Y');
zlabel ('V');
set(h,'xscale','log')
F = scatteredInterpolant(X(:),Y(:),V(:));
Warning: Duplicate data points have been detected and removed - corresponding values have been averaged.
Vq = F(Xq,Yq);
surf(Xq,Yq,Vq)
h=gca;
xlabel ('Xq');ylabel ('Yq');
zlabel ('Vq');
set(h,'xscale','log')
Can anyone tell what is the reason and how can I fix the noise in the results?
Thanks and best,
Ahmad

採用された回答

Bruno Luong
Bruno Luong 2022 年 8 月 7 日
The problem raises from the fact that scatteredInterpolant use Delaunay triangulation, meaning that X and Y are assumed to have the same unit.
In your case not only they do not have the proper normalization, but it seems X is log scale.
To fix it, you have to transform your variables:
load('Interpolation.mat');
ScaleLogX = 10;
ScaleY = 2000000;
F = scatteredInterpolant(log(X(:))/ScaleLogX,Y(:)/ScaleY,V(:));
Warning: Duplicate data points have been detected and removed - corresponding values have been averaged.
Vq = F(log(Xq)/ScaleLogX,Yq/ScaleY);
surf(Xq,Yq,Vq)
h=gca;
xlabel ('Xq');ylabel ('Yq');
zlabel ('Vq');
set(h,'xscale','log')

その他の回答 (1 件)

KSSV
KSSV 2022 年 8 月 7 日
編集済み: KSSV 2022 年 8 月 7 日
Read about griddata. Also explores the methods in these interpolations. Go for the method nearest.
  1 件のコメント
Ahmad Gad
Ahmad Gad 2022 年 8 月 7 日
The function griddata produced a very similar noise. I will try to explore different options in each function. Thanks for your comment.

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeInterpolation についてさらに検索

製品


リリース

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by