How to compute mean squared error of interpolated data?
Ältere Kommentare anzeigen
Hi, I was asked to compute the MSE of data that is interpolated using griddata() with respect to the original true data given by a computation formula. However when I tried it like this:
x = rand(200, 1);
y = rand(200, 1);
z = exp(x.^2).*y.*x;
[X,Y] = meshgrid(x,y);
Z = exp(X.^2).*Y.*X;
contour(X,Y,Z)
Zp = griddata(x,y,z,X,Y);
MSE = mean((Zp-Z).^2)
all element of MSE is NA, and the Zp is exactly the same as Z. Any hints why this didn't work out and how can I calculate the MSE correctly? Thanks!
Antworten (1)
Bjorn Gustavsson
am 3 Nov. 2020
0 Stimmen
Your problem is that the interpolation will, by definition, match the values of your data at the points of your data, just try the same thing for a 1-D set of points with interp1. If you want to make some non-linear fit of points to a scattered set of points (which might be the better way to go about the re-interpolation task when there's noise in your data), you could try matlab's spline-fitting function spap2, or some of the FEX-contributions - I've used gridfit, and there are newer tools that also handles higher-dimensional cases: regularizeNd.
HTH
Kategorien
Mehr zu Interpolation finden Sie in Hilfe-Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!