LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

linear fit with chart buffer

Solved!
Go to solution
I want to be able to graph both the data and the linear fit of the data stored in the chart buffer in real time.  I can't seem to figure out how to split the x and y arrays from the output on the chart buffer.  Any help would be appreciated.  I have attached a sample program.
0 Kudos
Message 1 of 8
(3,228 Views)

Heres one thing you could do:

Have your original data as two 1D arrays.

One is X values, and one is Y values.

Cluster those values together and that will be one data set.

 

Then, use the 'linear fit' function, and input your x and y arrays.

Use this new generated array of y-values and bundle them with the original array of x values.

 

If you build an array of the two data sets, then send them to an XY graph you should be all set.

Good luck 🙂

Sorry I cant open your VI, Im in 8.2, not 8.6 😞
Message Edited by Cory K on 02-16-2009 04:40 PM
Cory K
0 Kudos
Message 2 of 8
(3,204 Views)
Here is a pic of the block diagram.  I basically need the opposite of the index and bundle cluster array so that I can seperate the xy chart data.  Thanks
0 Kudos
Message 3 of 8
(3,194 Views)

Well, I guess we would really need to know what the output of the buffer is as well as what you want to fit.  The opposite of the bundle cluster is the "unbundle cluster" and you could write a loop to go through each element of the array.

 

 

-Matt Bradley

************ kudos always appreciated, but only when deserved **************************




0 Kudos
Message 4 of 8
(3,186 Views)

Is the image you showed me of your actual VI, or just an example?
That cluster is just one x value and one y value. How can you only fit one point to a curve?

You need to build an array of the x,y pairs each iteration

 

You would just need to use 'Unbundle' to split the x and y value.
Heres a sample of how your code should look.

 

The top half of the code was to take the data from being individual xy pairs, to an array of x values and an array of y values.

To split up the arrays and work with the data from there, you need whats in the red box.

Message Edited by Cory K on 02-17-2009 12:17 PM
Cory K
0 Kudos
Message 5 of 8
(3,154 Views)
Yea, the pic is my vi.  I see what you are saying and I understand that method.  The chart buffer shown in my vi has a input of one x and y, it stores those values and adds to them in the next iteration.  It outputs an array of clusters of x and y values.  That is what I want to be able to split and use with the linear fit vi.  Does that make more sense?  Thanks
Message Edited by secr1973 on 02-17-2009 12:42 PM
0 Kudos
Message 6 of 8
(3,141 Views)
Solution
Accepted by secr1973

secr1973 wrote:
Yea, the pic is my vi.  I see what you are saying and I understand that method.  The chart buffer shown in my vi has a input of one x and y, it stores those values and adds to them in the next iteration.  It outputs an array of clusters of x and y values.  That is what I want to be able to split and use with the linear fit vi.  Does that make more sense?  Thanks

OK, I understand what you are doing. But why use a buffer? You can just build an array use a shift register.

That way, the arrays will already be seperated.

Cory K
Message 7 of 8
(3,122 Views)
Your right, I really don't need the buffer. Thanks for your help.
0 Kudos
Message 8 of 8
(3,103 Views)