How to fit 3D surface to datasets (excluding specific datapoints) without Curve Fitting Toolbox

11 次查看(过去 30 天)
Hi all,
I want to fit a 3D surface to my dataset using a gaussian function — however, some of my data is saturated and I would like to exclude DATA above a specific value in my fit without removing columns or rows from my data.
I do not have the Matlab Curve Fitting Toolbox. I understand the Curve Fitting Toolbox can exclude datapoints from the fit without having to remove full rows — this is what I'd like to do here. Rmmissing is not the solution I am looking for as it deletes full rows.
My current code works well when I leave the saturated data in:
[OUTPUT, ~, RESIDUALS, ~, ~, ~, ~] = lsqcurvefit(FIT_FUNCTION, GUESSES, XY, DATA, LWR_BND, UPR_BND, OPTS);
but when I change the saturated cells to NaN (i.e. DATA(DATA>1000) = NaN), I get the following error:
'Finite difference Jacobian at initial point contains Inf or NaN values. lsqcurvefit cannot continue.'
Is there a way to exclude data above a specific integer value from a 3D fit without deleting rows/columns from my data?
Is there another solution other than using lsqcurvefit that would work? I have been unable to resolve this so far.
Thank you in advance!
Below is what I am working with in terms of MATLAB version and toolboxes:
MATLAB Version 9.9 (R2020b)
Image Processing Toolbox Version 11.2 (R2020b)
Optimization Toolbox Version 9.0 (R2020b)
Signal Processing Toolbox Version 8.5 (R2020b)
EDIT: re-worded question for clarity based on two answers given up to now.

采纳的回答

Joe Vinciguerra
Joe Vinciguerra 2023-4-6
I would recommend using either:
  1. rmmissing to remove NaN values, but be sure to remove the matching data points from your XY array also.
  2. fillmissing to replace NaN values with a predefined constant, method, or function.
Since you're trying to fit the data you probably don't want to use fillmissing, but that depends on your application and your dataset.
  7 个评论
Joe Vinciguerra
Joe Vinciguerra 2023-4-10
The Curve Fitting Toolbox would be appropriate for fitting surfaces.
However, you would still need to remove the NaN values as I described above. You don't need to remove entire ros and columns, just the (x,y,z) tuple if one of the components is NaN as I described above.
B.L.
B.L. 2023-4-10
Ok, I don't have this Toolbox at the moment, but will get a free trial to see if it works. If so, I will return to accept your answer.

请先登录,再进行评论。

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Interpolation 的更多信息

产品


版本

R2020b

Community Treasure Hunt

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

Start Hunting!

Translated by