Continue to Site

Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

  • Congratulations waross on being selected by the Eng-Tips community for having the most helpful posts in the forums last week. Way to Go!

How can I make a curve smoother?

Status
Not open for further replies.

nekovolta

Mechanical
Mar 20, 2012
8
Hi,

I am plotting a set or results I have, for instance (this is a piece of code):

X=[70:-3:0];
example=[1.6626E-12 3.4713E-12 1.2833E-11 5.0116E-11 1.9644E-10 7.7019E-10 3.0197E-09 1.1840E-08 4.6420E-08 1.8200E-07 7.1358E-07 2.7978E-06 1.0969E-05 4.3008E-05 1.6863E-04 6.6114E-04 2.5922E-03 1.0163E-02 3.9847E-02 1.5623E-01 6.1255E-01 1.0000E+00 1.0000E+00 1.0000E+00];
plot(X,example)

As you can see in the figure, as I do not have too many results in some points, there are sharp point that I'd like to make them smoother. I have been trying to do it with the functions 'polyfit and polyval' and on the other hand with the function 'smooth' but I didn't get the results I'd like to. Can any anyone give me any suggestion?

Thanks in advance!
 
Replies continue below

Recommended for you

Best if you explain what results you'd like. polyfit and smooth will do what they say. Your data is very much not smooth to start with, so any smoothing algorithm is going to struggle. Maybe you could try pre-processing the data first - only you know what pre-processing is valid given the data source, but you could start by doing something about that huge change in gradient at around X=8. What about just smoothing the data beyond that point? At least from then on it looks like there might be a satisfactory interpolation. For values of X<20, there are just not enough samples to form any conclusion on how the large changes in gradient should be smoothed.
 
Perhaps you should consider a spline fit. I think you need to decide whether it's plausible to have the curve smooth in certain spots. Certainly, from your data, there are points that have no plausible explanation for why they might be on a smooth curve.

TTFN
faq731-376
7ofakss

Need help writing a question or understanding a reply? forum1529
 
Without any description of what you don't like it is hard to answer but a quick stab and I would recommend monotonic interpolation maybe?

Here is a pic of what I mean is attached with the axis scaled to show the points I would be concerned about.

Hope that helps and good luck,

- J -
 
 http://files.engineering.com/getfile.aspx?folder=cc7e98e7-189a-47aa-a9ed-0723a1579ccc&file=pic1.png
Status
Not open for further replies.

Part and Inventory Search

Sponsor