cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
Showing results for 
Search instead for 
Did you mean: 

Community Tip - Learn all about the Community Ranking System, a fun gamification element of the PTC Community. X

Curve fitting

J_power
10-Marble

Curve fitting

Dear experts,

I have a question about curve fitting by using Mathcad.

I have a formula call Steinmetz's equation.

Jason_power_0-1692281985281.png

 

if I have a data like below figure.

Based on the Steinmetz's equation, I want to solve the "a" ,"b" and "k" from each frequency.

how do I use Mathcad to do the curve fitting.

Could you please give me some example.

 

 

Jason_power_3-1692282260929.png

 

 

 

 

 

ACCEPTED SOLUTION

Accepted Solutions
Werner_E
25-Diamond I
(To:J_power)

Here is an attempt to calculate just one set of parameters (a,b,k) which should fit all five curves.

The solve block used is not very sensible with respect to the guess values.

Werner_E_0-1692611035105.png

As you can see in the following plots, the fit isn't equally good for all curves. Of course you get better fits if you derive the parameters for each curve separately.

Werner_E_1-1692611134123.png

 

Attached sheet is in format Prime 6

 

View solution in original post

40 REPLIES 40
Werner_E
25-Diamond I
(To:J_power)

Looking up the information in he help about the function genfit() should help you.

Got it.

VladimirN
24-Ruby II
(To:J_power)

thanks.

ttokoro
20-Turquoise
(To:J_power)

Please share your Mathcad sheet that has your plot data set.

J_power
10-Marble
(To:ttokoro)

I know how to do it, thanks.

ttokoro
20-Turquoise
(To:ttokoro)

image.pngimage.pngimage.pngimage.png

J_power
10-Marble
(To:ttokoro)

Hi @ttokoro 

May I know what's kind of method did you use?

is it possible to share your Mathcad, thanks.

 

ttokoro
20-Turquoise
(To:J_power)

I just use Werner_E's solve block and also the one of Fred's log data to 3D plot data.  

 

image.pngimage.pngimage.pngimage.pngimage.png

J_power
10-Marble
(To:ttokoro)

it seems like the method you use is more accurate?

 

Werner_E
25-Diamond I
(To:J_power)


@J_power wrote:

it seems like the method you use is more accurate?

 


Why do you think so?

For a comparison of the two fits see here: https://community.ptc.com/t5/Mathcad/Curve-fitting/m-p/895688/highlight/true#M208272

Werner_E
25-Diamond I
(To:ttokoro)


@ttokoro wrote:

image.png


!! In Prime log(..) is used for lg(...), not for ln(...)

Hi,

Part of the input for the 'genfit()' function are two column vectors vx and vy being the data you intend fitting to.

So my question is do you have the original data that forms the graph or are you working only on an image of the graph?

If you only have the graph you will need a program like PlotDigitize to get some x,y values.  That is what I have done here.

Capture.JPG

@terryhendicott 

 

I have original data. 

Thanks for your advice. I know how to do.

by the way, I have other question.

if I have 5 curve in one plot. 

could I use genfit to find the coefficient?

for example, 

in your plot, you only draw 1150Hz curve in Mathcad and you use genfit to find the coefficient.

can I draw the all frequency to find the coefficient?

 

Hi,

You need to use genfit() five times to get the coefficients.  One for each line on the curve.

If the data was organised with vx being a matrix with each column being the B data for one line and vy being a matrix with each column being the data for one line in turn, you can use one genfit solution.  This would generate a nested matrix of k, a, b solutions.

Capture.JPG

Cheers

Hi,

 

Do you mean I will get k,a,b coefficient for each curve or I will get total solution for five curve.h version 

 

by the way, 

which Mathcad Prime version you use, I use 7, but I couldn't open it.

and I can't use genfit function in Mathcad 7 prime.

 

Hi,

Do you mean I will get k,a,b coefficient for each curve or I will get total solution for five curve.h version 

Yes you get five different coefficients one for each line.

Sorry Prime 9 only

Cheers

Terry

Hi

Is it possible to find a general solution for five all curve? 

or other method I can find the general solution for these.

because it is not very convenient  to find the solution for each curve.

 

 

 

Here is Terry's file for Prime7.

 

Success!
Luc

Hi @LucMeekes ,

Thanks.

the genfit() function could be used in Mathcad Prime 7? I search the Prime 7 document, there is no genfit() in there.

may I know how you transfer the version from 9 to 7?

Werner_E
25-Diamond I
(To:J_power)


@J_power wrote:

 

the genfit() function could be used in Mathcad Prime 7? I search the Prime 7 document, there is no genfit() in there.

Prime 7 definitely has "genfit" built in. See the help page here:  Nonlinear Regression

As its a "premium" function its not available if you are using the free Express version of Prime. So, do you use the full version or Prime Express? In the latter case you may have a look at Freds reply.

 


Is it possible to find a general solution for five all curve?

Yes, thats possible. Why don't you post the data?

Hi @Werner_E ,

 

OK, I know it. I can open it now.

please see the attached file.

this is my data points.

 

Hi @terryhendicott ,

 

When I open your v2 file, it think you don't use the method you mention, right?

it seems you define the new data.

Jason_power_1-1692541863523.png

Jason_power_2-1692541880683.png

 

Jason_power_0-1692541760339.jpeg

how do I define the 5 different data only using vx.

 

Cornel
19-Tanzanite
(To:J_power)

From where did you get that graph: Loss vs B (from which book/site/article/etc)? Do you only have the picture or also the data points?

J_power
10-Marble
(To:Cornel)

@Cornel  
I have data point in my side.

 

Express does not have access to "genfit."  But, by taking the logarithm of the equation we can turn it into something that least squares can deal with.  Attached is a sample in version 4.

 

Note that only one curve's data was used to develop the solution.  If the constants (k, a, b) are true physical parameters then the curves for other frequencies should also be correct.

Hi,

By the way Fred how did you get the red area line?

 

Fred's log techniue

Capture.JPG

genfit with start guess of 1,1,1. You can get a different k,a,b by changing the guess values

Capture2.JPG

So there are many solutions for k,a,b on the one curve. meaning it may be possible for one set of k,a,b for all curves

 

Please upload you data

Hi @terryhendicott ,

 

Sorry too late to upload the data.

please see the attached file.

I have five curve with different frequency in Excel file.

but I still can only find the solution case by case, 

Terry,

 

The red line at the top is a collapsed area that has errors inside it.  (Express is missing a lot of useful functions and gimmicks; I put them in a collapsed area at the top so they're there when I need them.  Turns out one expression has an error, so the area line turns red.

Announcements

Top Tags