LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How do I find slope of a waveform

This seems pretty simple but I'm having trouble with this:
I have a waveform that I need to filter to get only a subset of it (I'm ok with that part - using a lib vi), then take that subset, find its slope and intercept, then draw that line on the origninal waveform graph.
On the original waveform I have put in 0s for the first 100 ms of time, on my slope line I need to plug in the zeroed out x values with result of the slope equation.
Any suggestions appreciated.
Mike
0 Kudos
Message 1 of 18
(9,239 Views)
Slope is defined as dY / dX, where, in this case, your X-axis is time.
You could call it dY / dT.

d represents delta, or the difference between two Y values (or time-values).

Pick two points from your graph - T0,Y0, and T1,Y1

Your slope is (Y1 - Y0) / (T1 - T0)

If you're measuring volts, the slope is in Volts/second.

Simple, right?

The kicker is in picking the points to use. If you pick them close together, you run a larger risk of noise polluting your answer. If you pick them farther apart, you may miss some feature.

In your example data, if you pick T0 = 0.07, and T1 = 0.1, you'll get a negative slope.
If you pick T0 = 0.1 and T1 = 0.2 you'll get a positive slope.

If you pick T0 = 0.1 and T1 = 0.4, you'll get a lower positive slope.

All of them are correct, it depends on what you want to know.
Steve Bird
Culverson Software - Elegant software that is a pleasure to use.
Culverson.com


Blog for (mostly LabVIEW) programmers: Tips And Tricks

Message 2 of 18
(9,227 Views)
Mike,

The Linear Fit VI should do what you want. I modified your VI to inlude that. See if this is what you were trying to do.

Lynn
Message 3 of 18
(9,222 Views)
Lynne:
Yes. thank you so much, that is exactly what I was trying to do. WOW!
Mike
0 Kudos
Message 4 of 18
(9,210 Views)
Thank you for your help, that makes the problem a little easier.
Mike
0 Kudos
Message 5 of 18
(9,210 Views)
Hi Lynne:
After your reply to the problem I posed in this vi I thought I could take the equation of the line found in that subset data and project the line back to the Y axis. In the first part of the waveform, I had to plug zeros in for the data.
Now that the data from index 100 to 500 was analysed and equation of line found, I thought I could just extend that line back to where it would intersect the Y axis.
but what happens is the intercept value offsets the line.

I'm trying to interpolate and replace the data I filled with zeros with projected data.
I'm sorry to be such a pest.

Mike
0 Kudos
Message 6 of 18
(9,183 Views)
Mike,

When you take the waveform subset it effectively changes the location of the origin of your graph. I put a translation of coordinates into the VI so that Output Waveform 3 has its origin at the same place as the orignal Waveform Graph (I think). See if this put you on the track of what you wanted.

Lynn
0 Kudos
Message 7 of 18
(9,181 Views)
Hi Lynne:
Are you human?
I sat down with your vi for a while before I figured out what you did. I'm pretty sure it's what I wanted. Thank you for commenting it. I just want to clearify.
You wrote: [My questions in brackets]
Let z = mX + B where X and B are transformed variables
At x = 0, X is equal to the time corresponding to Start.
t (Start) = dt * Start [t is the startpoint time we took data?]
Then X = x + dt * Start
At x = 0, y = b and z = m * dt * Start + B = b [This is where I start to loose you.... is lowercase x the new zero point in waveform? so y at new zero is the old intercept (b)?]
So B = b - m * dt * Start [the new intercpept old intercpet minus slope times the startpoint of data?]
z = m * (x + dt * Start) + b - m * dt * Start

Thanks, I will experiment with all of this.
Mike
0 Kudos
Message 8 of 18
(9,166 Views)
Hi !

I am trying to achieve "smoothing" of my data and thought you could help.

The data is gauge value in mm (Y axis) and point of reading (X axis).
The problem is that we have high resolution sensors which tend of magnify even small surface irregularities leading of a graph which is very accurate but also confusing.
See attached image.

Is there some way I can smooth it out. Using median and moving average has helped but not as good as desired.

Thanks!

- Gurdas
Gurdas Sandhu, Ph.D.
ORISE Research Fellow at US EPA
0 Kudos
Message 9 of 18
(9,000 Views)
The plot image ...
Gurdas Sandhu, Ph.D.
ORISE Research Fellow at US EPA
0 Kudos
Message 10 of 18
(8,998 Views)