Community Tip - Stay updated on what is happening on the PTC Community by subscribing to PTC Community Announcements. X
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.
Send please your data X and Y vectors or/and thw Prime sheet.
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.
It looks to me that genfit works pretty well using the data you provided without modifications.
The values are not the same but similar to the ones you have from Octave.
You also can calculate the values using a solve block with minerr:
LeastSquaresFit works, too, but it takes very long to finish the calculation:
Thanks. Turns out my mistake was taking the time from column 0 and the voltage from column 3 without realizing that columns 2 and 3 had fewer data points so one of my vectors had a bunch of NaN entries.
I am just starting with Prime, had been using old MathCAD from the DOS version up through 15. I run into a lot of things that are slightly different in Prime...
I run into a lot of things that are slightly different in Prime...
"slightly different" - this is a very well-intentioned euphemism 🙂
In fact, Prime is far inferior to the old Mathcad in terms of functionality and ease of use. And when it comes to the scrolling in large matrices you mentioned earlier, that's just terrible. It looks like a childish programmer has played around with a programmers toolbox without thinking too much.
Admittedly, Prime also has a few advantages (such as entering matrices or using different units in a matrix, as with the vector beta). But the bottom line is that Prime is a long way from being compared to Mathcad.