# LabVIEW

cancel
Showing results for
Did you mean:

Solved!
Go to solution

## linear fit with chart buffer

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.
Message 1 of 8
(3,228 Views)

## Re: linear fit with chart buffer

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
Message 2 of 8
(3,204 Views)

## Re: linear fit with chart buffer

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
Message 3 of 8
(3,194 Views)

## Re: linear fit with chart buffer

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.

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

Message 4 of 8
(3,186 Views)

## Re: linear fit with chart buffer

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
Message 5 of 8
(3,154 Views)

## Re: linear fit with chart buffer

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
Message 6 of 8
(3,141 Views)
Solution
Accepted by secr1973

## Re: linear fit with chart buffer

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)

## Re: linear fit with chart buffer

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