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

8 ビュー (過去 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 Center および File ExchangeInterpolation についてさらに検索

製品


リリース

R2020b

Community Treasure Hunt

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

Start Hunting!

Translated by