Skip to main content
1-Visitor
April 7, 2021
Question

Trouble with nonlinear curve fitting functions

  • April 7, 2021
  • 1 reply
  • 4021 views

 

I am moving some calculations from Octave (open-source MATLAB clone) for Prime 7.0. One of the calculations involves fitting a double exponential pulse to measured data. In Octave/MATLAB I use the lsqcurvefit function, which executes very quickly and appears to give me reasonable answers.

 

I am trying to find an equivalent function in MathCAD Prime. I tried genfit and LeastSquaresFit - for genfit I get a regression not converging error, for LeastSquaresFit I get  a floating point error. I even tried using the output of my MATLAB calculation as the guess value and still get these errors.

 

Here is a screenshot showing the function I am trying to fit, the guess value (which is the output from MATLAB), and a plot of the data and the fitting function using the guess value.

 

I assume I am doing something fundamentally wrong here. In MATLAB I can start with a guess value wildly in error and still get an answer.

 

 

MW_9516524_0-1617818980819.png

1 reply

24-Ruby IV
April 7, 2021

Send please your data X and Y vectors or/and thw Prime sheet.

mikewu991-VisitorAuthor
1-Visitor
April 7, 2021

Here is the sheet and the data file.

mikewu991-VisitorAuthor
1-Visitor
April 7, 2021

I finally figured how to scroll down in the numeric display of the vector (very different between 15 and Prime) and found an format error in my input data. The genfit function appear to work now.