Skip to main content
1-Visitor
January 23, 2018
Question

Calculating slope in dataset

  • January 23, 2018
  • 3 replies
  • 13693 views

Hello everyone,

 

I have lots of datasets with different embankment profiles, see picture for example. Each embankment contains 1 or 2 slopes. 

 

Is it possible to calculate the slope (in this case 2) within the profile. How do I select my boundaries for each slope on the x axis. I can connect my data trough excel as import or make x-y tables/matrixes in mathcad.

 

I use mathcad prime version 3.

 

vraag mathcad.PNG

 

Thanks in advance

 

Gerwin

 

ps seems I posted in wrong forum section. Can a moderater move my post to a more apropriate place?

3 replies

25-Diamond I
January 23, 2018

How would you define a "slope" in your case?

It would be a good idea to attach a worksheet (you may have to zip it frst to be able to do so because of a nasty bug in the forum software here) with some more example curves.

 
GvanBoven1-VisitorAuthor
1-Visitor
January 24, 2018

Let me try to clarify a little bit more and add a file with the data of the profile.

 

In the profile you can see 2 slopes

-1 small one in between 2-12

-2 and a large one in between 72-130.

 

I would like to calclate the slope of both. I started out with 1. Can mathcad predict the begin and endpoints of slope locations if the data would change a little and what happens if there is like a gap in my data(or is this going to be user input in my sheet). The data in this case is a geometric profile of an embankment.

25-Diamond I
January 24, 2018

Unfortunately I can't open Prime files from versions greater than 3.0 at the time.

But to make it clear:

You are interested in the regions where your signal has a slop (a first derivative) different from zero.

And you want Mathcad to determine those sections (Mathcad sure can't predict anything which will change if you change your data in an unspecified way).

It may be possible to do. You may create a spline interpolation function (maybe smoothing the data first), define its derivative and look for the regions where the absolute value of the derivative is grater than a specified threshold. The range from 135 to 450 sure has a slightly positive, non-zero slope but obviously not big enough for you to be interested in.

A second idea would be to simply look for positions where the derivative changes sharply. Maybe looking at the second derivative.

In any case its sort of playing around to find a suitable algorithm and it sure would be necessary to have access to more than just one set of data.

23-Emerald I
January 23, 2018

You have a set of data pairs, (x,y).  There are a number of curve fitting possibilities, looking at your example I'd be inclined to look at fitting a spline.  The steps are these:

  1. Smooth the data first if necessary.  (Might want to try without smoothing first to see how bad it is.)
  2. Define a function Y(x) using the vectors x and y.  (This allows Mathcad to interpolate between your points.)
  3. Define the function Slp(x) := dY(x)/dx.  (There's a derivative operator.)
  4. Plot your result. 

You may want to split your data up into pieces and fit straight lines to the segments; that's doable but would be challenging to automate.

25-Diamond I
January 25, 2018

Here are some attempts to automate the finding of the segments with a higher (speaking of the absolute value) slope than a given threshold which does not use an interpolating function and its derivative.

The first approach would need a different kind of smoothing function, I guess

Bild1.PNG

 

The second approach might be useful. You may have to play around with the parameters and I can't tell if one set of  parameters would be appropriate for all your data sets - you had just provided one.

Bild2.PNG

The sheet was created in Mathcad 15 (what else) and I attach the original MC 15 sheet along with a pdf print as well as a converted Prime 4.0 sheet.

Guess there sure are people out there able to provide a file converted to Prime 3.0 if necessary.

 

 
GvanBoven1-VisitorAuthor
1-Visitor
January 26, 2018

Thanks all for the responses. Ive been busy with another project that had to be done quick so I did not have time to respond or check any of the solutions. Ive seen a couple of interesting pictures and will take some time soon to see if there is anything in here that can help me.

25-Diamond I
January 26, 2018

Here are two more attempts, using a numeric discrete derivative but again no interpolating function.

You'll have to give it a try with some others of your data sets.

Bild.PNG

 

Sorry, can't attach a Prime 3.0 sheet at the moment. If you ask I am sure someone will be able to convert the MC15 file to Prime 3.