LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Data processing - Algorithm

Hi,

 

I'm trying to create some type of algorithm to separate a data array in two different arrays.

I have a data array, which contains two columns and 3000 rows of data. This data represents a function shape, so the first column is for the "y" axis and the second one corresponds to the "x" axis. The values of the data are growing and decreasing all over the file.

The problem is that the function goes through the same point 2 times but with other behaviour, so I have 2 different values for the same "x" value.

As the data is quite estable, I have build a system to differenciate if the data is growing or decreasing and then separate it, but the method I used is slow and not efficient. Also, if the data variase too much, up and down this wouldn't be a valid sollution.

What I did is to initialize the new two arrays and set the "for loop" to the amount of data in the first array. Then I compare the current value with another value 10 steps further and depending on the result I insert those values into "Growing Data" or "Decreasing Data".LabVIEW.JPG

 

I would like to know if there is another posibility.

Thanks in advance.

 

 

 

0 Kudos
Message 1 of 8
(3,681 Views)

A couple of points.  Please post your code as a VI (you can put a picture in your Post, but also attach the VI as an "attachment").  Having the VI to examine lets us examine things we can't see (such as the False limb of your Case Statement), as well as test and modify your code.

 

I'm a little confused about the nature of your data.  Is this a function of two variables, X and Y (so it would be plotted on a 3D graph) or is it a function Y = F(X), which can be plotted on a 2D graph?  Is there an order to the points, i.e. are they samples taken at equally space time points?  [This might correspond to a "journey" on a 2D surface].

 

Something that might be useful for us to have to understand your question is a "file of data", 2 columns and 3000 rows.  Is this an Excel WorkSheet (.xls), a text file (.csv or .txt), or something else?  Excel or Text are easiest to handle ...  Also, if you have a plot of the data so we can better understand "The data represents a function shape", that would be helpful.

 

Bob Schor

Message 2 of 8
(3,661 Views)

You are subtracting two different floating point numbers and seeing if they are equal to zero.  It is very possible that you have numbers that appear to be the same, but to the computer have a miniscule difference that makes them not equal to zero when you subtract.

Message 3 of 8
(3,657 Views)

As RavensFan said, you must never ever do equality checks on floating point numbers. A better way to do it would be to check if the absolute value of their difference is less than some threshold in terms of Machine Epsilon, like so:

 

 

I've attached the VI. You can set tolerance to be just a normal constant, but make sure it's greater than 1. I use a tolerance of 10^6 in my applications, which serves pretty well.

Message 4 of 8
(3,625 Views)

Hi,

 

Thanks for the response. I will try to upload the vi as soon as posible, but the false state is just the same witha different array indicator.

Regarding thedatam it's a vasic 2D graph. One column represents the "X" axis and the other one the "Y" one, where Y=F(X).

The data is collected taking intto account the time, so the "X" values are not changin constantly. The data goes from the minimum "X" value, increasing until it reaches the maximum point, and then it goes down until it reaches the minimum point of "X" again.

Captura.JPG

The data graph is similar to this one above. I said it was representing a function shape because its almost a hysteresis curve.

The data file contains all the points of the graph above (it's not a real graph). 

My goal is to separate both curves into two different data arrays. My method analyses each one of the  "X" data points to insert them into the corresponding array. Since there is a lot of data to process (3000 at least) this takes a lot of time. If there is any way of identifying the end of the first curve and cut the array into two or another method, please tell me.

 

Thanks in advance.

0 Kudos
Message 5 of 8
(3,594 Views)

Thanks Ravens,

 

I will take that into accout.

0 Kudos
Message 6 of 8
(3,592 Views)

Thanks,

 

I will try to use your method instead.

Thanks for the support.

0 Kudos
Message 7 of 8
(3,589 Views)

This looks like a pretty normal physical process where the 2D curve shown is built over time by simply marching around the perimeter.  Point being, knowledge of the physical process can help you simplify your algorithm with some reasonable assumptions.

 

If your main goal is to separate the data for the upper curve from the data for the lower curve, I would feed the full set of "X" data into an Array Max & Min function.  That'll identify the row numbers where both Max and Min are found.

 

Odds are, you start the test from either Xmin or Xmax, so you only need to "find" the other one.  When you do, that index is the row that will split your data into separate upper and lower curves.

 

Tiny little detailed refinements may be appropriate for your situation, but this'll likely get you darn close really easily.

 

 

-Kevin P

CAUTION! New LabVIEW adopters -- it's too late for me, but you *can* save yourself. The new subscription policy for LabVIEW puts NI's hand in your wallet for the rest of your working life. Are you sure you're *that* dedicated to LabVIEW? (Summary of my reasons in this post, part of a voluminous thread of mostly complaints starting here).
0 Kudos
Message 8 of 8
(3,531 Views)