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

Community Tip - Did you know you can set a signature that will be added to all your posts? Set it here! X

Best Smoothing Approach

ppal
17-Peridot

Best Smoothing Approach

Hi

Help with smoothing function please.

I am having issues formulation a smoothing function. Errors like "This value must be a vector of real numbers: pop up.

A working example will help a lot. 

Prime 6 File Attached.

muser_0-1616730394451.png

 

1 ACCEPTED SOLUTION

Accepted Solutions
ppal
17-Peridot
(To:Werner_E)

l having problems plotting.

Mathcad and Excel file attached for your help please.

View solution in original post

12 REPLIES 12
Werner_E
24-Ruby V
(To:ppal)

Your approach failed because i is not a vector but a range!

In the pic below I used an undocumented trick to turn a range into a vector by adding a numeric evaluation when defining the variable i. Furthermore I chose the first value to be 1 instead of zero so the magnitude of i and r.dom match.

Werner_E_0-1616736919902.png

But of course you are on the save side if you define the necessary vector the "legal" way:

Werner_E_1-1616737210004.png

 

A working example can also be found in the help

https://support.ptc.com/help/mathcad/r6.0/en/index.html#page/PTC_Mathcad_Help%2Fexample_adaptive_smoothing.html%23wwID0EFBUV

 

You may also be interested in the information about smoothing in the MC15 help. Find it converted to pdf in the attachments.

 

DJF
16-Pearl
16-Pearl
(To:Werner_E)

Is it possible to integrate the supsmooth function?

Werner_E
24-Ruby V
(To:DJF)


@DJF wrote:

Is it possible to integrate the supsmooth function?

 


supsmooth does not return a function but rather a vector of y-values corresponding to the vector of x-values provided.

You either can write your own "integration" function which works on datapoints given by vectors or you use interpolation (either linear or cubic splines) to turn the result of supsmooth into a function.

 

tietjee
14-Alexandrite
(To:Werner_E)

A function for the supsmooth can be defined using the x and y vectors with interp function.  This new function can be integrated.

DJF
16-Pearl
16-Pearl
(To:tietjee)

I see.  So, then no real advantage to using supsmooth over say a b-spline (unless you happen to like the fit better).  was hoping to save a step.  Thanks all.

ppal
17-Peridot
(To:Werner_E)

l having problems plotting.

Mathcad and Excel file attached for your help please.

LucMeekes
23-Emerald III
(To:ppal)

What's the problem...it plots

LucMeekes_0-1617015890095.png

doesn't it?

 

Luc

ppal
17-Peridot
(To:LucMeekes)

Sorry wasn’t clear. Can’t plot the smoothed  data.

Werner_E
24-Ruby V
(To:ppal)

I don't  see any attempt to plot r.smooth ??

Maybe you just have to move down the plot below the definition of r.smooth?

Werner_E_0-1617066490579.png

 

ppal
17-Peridot
(To:Werner_E)

Thanks!

Werner_E
24-Ruby V
(To:ppal)

An additional remark:

It looks like you got confused by the indexing of vectors. By default Prime starts with zero.

You defined your range i starting from 1 and then plotted Loc[i over i. That way your plot gets shifted to the left for 1 unit - the first value of your data vector "Loc" is ignored and the second one (index 1) is assigned to 1, etc.

Correct plot should look that way:

Werner_E_0-1617095943847.png

 

ppal
17-Peridot
(To:Werner_E)

Thanks for spotting that.

Top Tags