Surface Fit off in one corner of a polynomial surface
1 Ansicht (letzte 30 Tage)
Ältere Kommentare anzeigen
I am trying to fit a surface to some noisy data so that this surface can be subtracted from the data to normalize the background. However when I fit the fit is good except at one corner where it is way off (see picture). Does anyone have a suggestion on how to get the surface to fit the data in the corner more closely.
Poly 55 seems to work better than poly44 or poly 33.
Another option i did was to break the 2D matrix into vectors and fit a curve to each row vector which worked very well with poly4. But I would like to solve this problem with surface fitting.
Thanks.
The code I am using is:
[f gof] = fit([xdata',ydata'],zdata', 'poly55')
plot(f, [xdata',ydata'],zdata')
0 Kommentare
Antworten (1)
Vinayak
am 23 Mai 2024
Hi matthias,
As you want to fit some noisy data with problematic regions in the corners, I would recommend weighted fitting as you are aware of regions of concern. Assigning more weights to significant data points will make the fitting algorithm prioritize these points.
You can get the indices of the regions using conditional indexing, and later assign higher weights to them. You can use the same poly55 or another similar fitting algorithm to get a better fit.
% Find indices
corner_indices = (xdata < corner_x_threshold) & (ydata < corner_y_threshold);
% Assign weights
weights = ones(size(zdata));
weights(corner_indices) = 10; % Increase the weight for the corner region
% Perform the fit with weights
[f, gof] = fit([xdata', ydata'], zdata', 'poly55', 'Weights', weights);
This should resolve the issue you are facing with underfitting around the corners.
0 Kommentare
Siehe auch
Kategorien
Mehr zu Get Started with Curve Fitting Toolbox 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!