×
INTELLIGENT WORK FORUMS
FOR ENGINEERING PROFESSIONALS

Are you an
Engineering professional?
Join Eng-Tips Forums!
• Talk With Other Members
• Be Notified Of Responses
• Keyword Search
Favorite Forums
• Automated Signatures
• Best Of All, It's Free!

*Eng-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

#### Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

# How to get slope of discrete data

## How to get slope of discrete data

(OP)
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.

### RE: How to get slope of discrete data

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.

### RE: How to get slope of discrete data

(OP)
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.

### RE: How to get slope of discrete data

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

### RE: How to get slope of discrete data

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.

### RE: How to get slope of discrete data

(OP)
Thank you all. My data is quite good.

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

Mapi

### RE: How to get slope of discrete data

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.

### RE: How to get slope of discrete data

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

Mapi

#### Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

#### Red Flag Submitted

Thank you for helping keep Eng-Tips Forums free from inappropriate posts.
The Eng-Tips staff will check this out and take appropriate action.

Close Box

# Join Eng-Tips® Today!

Join your peers on the Internet's largest technical engineering professional community.
It's easy to join and it's free.

Here's Why Members Love Eng-Tips Forums:

• Talk To Other Members
• Notification Of Responses To Questions
• Favorite Forums One Click Access
• Keyword Search Of All Posts, And More...

Register now while it's still free!