LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Trying to fit output of XY Graph

Solved!
Go to solution

Hello, I'm trying to fit the output of an XY graph which is (1-D Array of Cluster of 2 Elements(2x 1-D Array of Double[64-bit Real])). It seems like instead of having one array with two columns X,Y indexed persample number, I want to have a 1-D Array of Column Y , indexed by X. Any ideas?

 

Thanks.

0 Kudos
Message 1 of 16
(4,624 Views)

Uncluster the 1-D array that is outputted.

Then, you will have two seperate 1-D arrays, one for x's and one for y's.

Then when you index the array, use the same index for both arrays to get the (x,y) point. 

Cory K
0 Kudos
Message 2 of 16
(4,618 Views)
I'm not sure I completely understand what you're asking. If you have a 1D array of clusters that implies that you have a multiplot XY Graph. Is this what you have? In this case are you trying to fit a curve to one of the traces? An XY graph basically consists of 2 arrays of the same length: an array of X values and an array of Y values. The X values do not need to be evenly spaced. There really isn't a concept of "sample number" for XY graphs unless you're considering the index of the array of X values the "sample number".
0 Kudos
Message 3 of 16
(4,617 Views)

If you are trying to fit the data to some curve,

split the array into the two arrays.
One of x's and one of y's.

  

Then use those arrays as inputs to the fit function. 

 

 

Message Edited by Cory K on 11-04-2008 04:21 PM
Cory K
0 Kudos
Message 4 of 16
(4,616 Views)

I'm getting NaN on the slope and intercept outputs, is there a way to take the output of the XY Graph Local Variable feed it into the Curve Fitting VI and then add the fitted curve back into the XY graph? It seems like it does not like the Output of the Graph.

 

Thanks. 

0 Kudos
Message 5 of 16
(4,572 Views)

Hi!

 

I noticed that the XYGraph in your program is a 1D Array of clusters. You can build an XY Graph that way or build it as a cluster of 1D Arrays. It makes a difference in a lot of applications that depend on how the data is treated. Using the 2nd type of XY Graph, I was able to get the fitting values, but with the 1st way (what you're using now) I also got NaN. See the attached picture. Can you change the type of data in your graph and get the fitting to work?

Message Edited by LaRisa_S on 11-05-2008 01:56 PM
Product Support Engineer
National Instruments
0 Kudos
Message 6 of 16
(4,537 Views)

lefterisa wrote:

I'm getting NaN on the slope and intercept outputs, is there a way to take the output of the XY Graph Local Variable feed it into the Curve Fitting VI and then add the fitted curve back into the XY graph? It seems like it does not like the Output of the Graph.

 

Thanks. 


 

I have not seen any of your data, it may not be linear. If it is not linear, dont try to look for a constant slope.
Instead, use a derivative function to find the changing slope (uh-oh, this brings back haunting days of calculus).

When I used a linear fit, I was just giving you an example. Use whatever function you think is necessary.

Message Edited by Cory K on 11-06-2008 05:24 PM
Cory K
0 Kudos
Message 7 of 16
(4,510 Views)

lefterisa wrote:

I'm getting NaN on the slope and intercept outputs, is there a way to take the output of the XY Graph Local Variable feed it into the Curve Fitting VI and then add the fitted curve back into the XY graph?


 

 

Please attach your VI and some typical data. Most likely one of your points is NaN, in which case the linear fit will fail of course.

 

You really have some misconceptions. An XY graph is a data sink, and not a data source and faking it with local variables just complicates things. 🙂

 

So what you should do it take the output from the xy express VI, remove the points containing NaN, do the linear fit, and send both to the same xy graph terminal. You only need to write to the graph once.

Message Edited by altenbach on 11-06-2008 03:37 PM
0 Kudos
Message 8 of 16
(4,501 Views)

Is there a way to feed the data of an XY graph into a Curve Fit VI? The reason I'd like to do it this way is that the end user can rescale the Data on the XY Graph using the Tools Pallette and this modified Data set will be passed along with all the resized axis information, thus eliminating the need to resize the arrays and  reading  and writing to all the property nodes.

 

Thank you everybody for all your help.

 

 

0 Kudos
Message 9 of 16
(4,469 Views)

Changing e.g. the scales on an xy graph will not modify the underlying data.

 

Please attach a simplified VI example containing typical data.

0 Kudos
Message 10 of 16
(4,464 Views)