필터 지우기
필터 지우기

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

조회 수: 15 (최근 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에서 Get Started with Curve Fitting Toolbox에 대해 자세히 알아보기

제품


릴리스

R2020b

Community Treasure Hunt

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

Start Hunting!

Translated by