Skip to main content
1-Visitor
January 14, 2013
Solved

find intercept value of curve

  • January 14, 2013
  • 6 replies
  • 13551 views

Hello,

totally new to Mathcad, the help files are not of great help at all.

How do I find the Y value of the below curve where it intercepts the Y axis?

The data comes from a CSV where one column is used for X and the other for Y. My goal is to connect the start of this curve to the end. Then I would like to find the maximum difference between the straight line and the actual curve (the X value).

For now I can't even find out how to find the intersection value. I would not like to use a minimum/maximum function as the curve may look completely different for other datasets. The red line is created via the intercept function but it gives me the wrong starting value.

I appreciate the help.

Best answer by Werner_E

I have just added some comments, the maximal vertical deviation (which will not be of value, I know) and an alternate (but more cumbersome) way to define the ideal sensors characteristics via a function in contrast to the former data vector.

Just edited the file to take in account that the curve starts at 0G in any case.

Last edit for this post: added the max horizontal diff in the graph

6 replies

1-Visitor
January 14, 2013

If you type your function "ech(posline,4000)" you should get an array or vector. It looks like the first value is where Y = 0. If you want a specific term in the array, type "ech(posline,4000)[0" to get the first value in the array.

I hope this helps.

Norm

1-Visitor
January 14, 2013

Mmh, yes for this specific curve the 1st value will be ok. But I wanted to avoid using the 1st value because the 1st value might not always be the lowest.

However if I ask a more generic question. How do I find the Y value of a curve where it passes through the Y axis?

I think the "match" function can work but I can't figure out how. The "match" function seems to give me the position of the value I'm looking for (in the matrix) but not the value itself.

Let's take this example and imagine I have a CSV with two colums and the result of putting them into a XY graph gives me the following picture:

parabol.PNG

1-Visitor
January 14, 2013
1-Visitor
January 14, 2013

Thank you all very much. I'll try that tomorrow and let you know if I can get it to work.

Regards

25-Diamond I
January 15, 2013

The red line is created via the intercept function but it gives me the wrong starting value.

"line" (and "intercept" and "slope") are not supposed to connect the first (or whatever) and last point of a set of data points but rather calculate the line of regression, which fits the data points best using least square fit. Its a linear approximation, not an interpolation. Usually not a single point of your data would be part of that line of regression.

What is it you want to achieve exactly? Really conncting the point of intersection with the ordinate axis with the last(?) data point? Are you sure that ther is only one ordinate value for abcissa = 0 in your vectors?

I am not sure what meaning that kind of straight line would have.

Maybe you post a worksheet with different sets of data to clarify.

1-Visitor
January 15, 2013

Hello,

first of all thanks for the help.

This data represents the gain of a magnetic sensor. the X axis shows the magnetic field strength and the Y axis shows the output of the sensor in mV.

The CSV file is 400000 lines long, much to long to post it here.

The goal is to find the maximum deviation from an ideal sensor, which would be a straight line.

Therefore what I'm trying to do is to create first the ideal line connecting start and end point. I found them now with the lookup function.

But now I am stuck with the wrong slope. How do I create the slope from start to end point?

slope(startpoint,endpoint) doesn't work, it gives me an error saying something like "requires real numbers" (it's in french)

Thankscurve.PNG

12-Amethyst
January 15, 2013

If you have start & end points then fitting a line is relatively straight forward (see attached).

regards

Andy

Werner_E25-Diamond IAnswer
25-Diamond I
January 16, 2013

I have just added some comments, the maximal vertical deviation (which will not be of value, I know) and an alternate (but more cumbersome) way to define the ideal sensors characteristics via a function in contrast to the former data vector.

Just edited the file to take in account that the curve starts at 0G in any case.

Last edit for this post: added the max horizontal diff in the graph

1-Visitor
January 16, 2013

Amazing!

That's what I wanted.

I'll soon be back with more annoying questions.

Thanks for your time and effort, guys!

25-Diamond I
January 16, 2013

That's what I wanted.

Fine!

I'll soon be back with more annoying questions.

Feel free to do so 🙂

Thanks for your time and effort, guys!

You're welcome!

1-Visitor
January 16, 2013

Here it comes:

How do I define a range of indexes?

Following Werners example:

dev.PNG

posField contains data ranging from 0G to 4G. How can I limit the range in which "max" searches to a certain value contained in posField?

Ex: "max" returns a maximum deviation that lies after 3G (it considers the whole curve). I want "max" to return a maximum deviation that exists before 3G.

25-Diamond I
January 16, 2013

posField contains data ranging from 0G to 4G. How can I limit the range in which "max" searches to a certain value contained in posField?

Ex: "max" returns a maximum deviation that lies after 3G (it considers the whole curve). I want "max" to return a maximum deviation that exists before 3G.

Seems you are just answering my continous question baout the definition of the endpoint 🙂

If you want to discard all data with field greater 3G (and I assume field <0, too), I would do that at the very beginning after reading the data and proceed as shown.

I really like the new modifiers for the lookup functions. Its a pity they don't work with units.

16.01.png

If you need the data above 3G for some reason up to the point you calculate the horizontal diff, you would have to trim the vector hdeviation accordingly before applying max.

25-Diamond I
January 16, 2013

Some additional questions:

1) Can you guarantee that the data is always sorted in respect to the field values?

2) How do you deal with the situation if 0G is not included in your dataset? Lets say the nearest data point is at (0.2 G / -5 mV). Then, as the worksheet is written, the ideal sensors characteristics will begin at (0/-5) while the real sensors runs through (0.2/-5). Change in my file the 0 in posField to 0.2 and see yourself. In one of the first worksheets I posted, I dealt with that situation by using a spline interpolation, but this was deleted later.

3) Do you expect datasets with neagtive field values? I guess - no.?