Issue with gradient of interpolated data

조회 수: 4 (최근 30일)
Samantha
Samantha 2023년 11월 7일
편집: Matt J 2023년 11월 7일
I've used the scatteredInterpolant function to interpolate irregular velocity data. I use this to calculate the effective strain rate, which looks reasonable, but when I take the gradient of this data it seems to be "catching" on all the edges of my grid. It also looks like my interpolant to a regular grid isn't working?
In my attached image, on the top row I have my plots and the bottom are what my plots should sort of represent. On the top left is the results that don't really make sense, with really high and low values along the edges of the grid. On the top right is what I am taking the gradient of, which looks pretty good.
Any advice on my use of the scatteredInterpolant or debugging the gradient would be very very appreciated!
Here is the relevant code:
% Convert x and y data to regular grid. xy is loaded into file
xi = min(xy(:,1))-dx:dx:max(xy(:,1))+dx;
yi = (min(xy(:,2))-dy:dy:max(xy(:,2))+dy);
[xxx,yyy] = ndgrid(xi,yi);
us = scatteredInterpolant(xy(:,1),xy(:,2),u, 'linear', 'none');
vs = scatteredInterpolant(xy(:,1),xy(:,2),v, 'linear', 'none');
% Evalaute interpolants on gridded data
vv = vs(xxx,yyy)*3.154E7;
uu = us(xxx,yyy)*3.154E7;
[ux , uy] = gradient(uu,dx,dy);
[vx , vy] = gradient(vv,dx,dy);
e_eff = sqrt(.5*(ux.^2 + vy.^2) + (.5*(uy + vx)).^2);
% This line below looks like its the issue
[e_effx, e_effy] = gradient(e_eff.^(1/3-1),dx,dy);
  댓글 수: 1
Star Strider
Star Strider 2023년 11월 7일
I’m not certain what the problem is, however taking the numerical derivative amplifies noise, and that may be what you’re seeing.
Using a lowpass filter first, before calculating the gradient, might be an option to reduce any high-frequency noise and high-frequency transitions that may be in your data. First, calculate the Fourier transform of the data to see what stopband frequency value could be appropriate.

댓글을 달려면 로그인하십시오.

답변 (1개)

Matt J
Matt J 2023년 11월 7일
편집: Matt J 2023년 11월 7일

카테고리

Help CenterFile Exchange에서 Interpolation에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by