Issue with gradient of interpolated data
4 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
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 Kommentar
Star Strider
am 7 Nov. 2023
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.
Siehe auch
Kategorien
Mehr zu Interpolation finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!