Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

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

How to get slope of discrete data

Status
Not open for further replies.

mapi

Mechanical
Joined
Jan 30, 2007
Messages
53
Location
US
Hi,
I have discrete data which can be some kind of curve. Now if we don't use a function to fit the data, and just based on these discrete data, can we get the approximate slope?

Thanks.
 
I'm not understanding your requirements. A "slope," by definition, implies a model, i.e., that the data fits a straight line. If you have no model, you have nothing but raw data.

TTFN

FAQ731-376
 
In matlab, I just find that we can use function 'diff' to calculate the approximate slope.

if we have y-x data, then diff(y)./diff(x) gives rough slopes at different points.
 
diff()./diff() is the obvious answer. gradient() is better. There's no rocket science involved, but it does mean you don't need to do all the end treatment stuff yourself.

- Steve
 
That's fine if you have ZERO noise and ZERO measurement error. If you do have noise or measurement errors, then the slopes you generate are going to be relatively meaningless.

If your data doesn't fall on a line, then I'm not sure what you're trying to accomplish. If your trying to interpolate or do a prediction, then you should be fitting to a polynomial or something similar to mitigate the noise impact.

If your data are on a line, then you should fit to a line to get the best data possible.

TTFN

FAQ731-376
 
Thank you all. My data is quite good.

I will try both diff (or gradient) and fitting to a simple function.

Mapi
 
Perhaps you need to explain what the end goal is, and what the data represents. Have you even graphed the data? Why are you going through this exercise without knowing what the result should look like. Seems like creating unnecessary busywork.

TTFN

FAQ731-376
 
My data is stress-strain data (nonlinear curve). I need to determine the Young's modulus (the slope).

Mapi
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top