LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Creating graphs/plot/pirctures - HELP

Solved!
Go to solution

My program gathers sampled data and a user defined interval.  It then does a simple linear regression y = m*x + b where m = Cov[x,y]/Var[x] and b = y-bar - m*x-bar.  After these calculations are down I want to plot the scatter plot of the data and overlay the line definied by the equation produced in the regression and then display it on the front panel.

 

My current attempt is to use Plot Multi-XY.vi to plot each set of x's and y'x on one picture and then place each picture for each channel in an array of pictures.  Then the user can look at each one by going through the array.  The error I get has to do with the data type.  I feel like it is fairly difficult to type what I am trying to say so I included a screen shot of the area of my VI that is causing the error.  I end up using the variant to data vi to convert my data to the proper data-type.  When I use a data constant it breaks the lines but if I use a variant constant it is fine - but then I get a "type" error.  I'm not too familiar with using variants and data-types so any help would be appreciated.  I have most of the code done for this program I'm just working out the bugs and this is where I am hung up on at the moment.

 

Thanks in advance.

 

usinPlotXY.png

0 Kudos
Message 1 of 4
(2,565 Views)

Upon taking a closer look at what my program was doing and what the data types were and how they were "clustered" and "arrayed" together I thought it would work, but I get the same error.  Changes and error are included below.  Now I'm really not sure why it's not working.  Each cluster going into the for loop contains the data I want to plot together.  So each loop makes the two data sets available to plot.  Then as you can see I take the cluster and convert it to a data type (the cluster contains the two doubles needed in the data type). Then put each result in a cluster and then in an array before converting it to the data type for the Plot Multi-XY.vi

 

So by my math that should be:  Data (1D) -> Cluster (1 element)  -> Data (1D) -> Cluster (2 elements) (DLB's)

 

I hope my notation above is understandable.  Unless I'm missing something there I would think it would work.  Thanks again.

 

 

usinPlotXYfixed.png                                        error.png

0 Kudos
Message 2 of 4
(2,554 Views)
Solution
Accepted by topic author joedowdle

Hi,

you are missing the fact, that you are trying to convert data from one datatype to another using a wrong way 🙂

 

You cannoth convert different data types using Data type -> Variant -> New Data type.

You have to manually unbundle in a for loop and rebundle the data into the new datatype.

 

Taking a closer look, you seem to create (that part of code is not whole visible) the data as array.

 

The Plot object eats Array of Plots !

Create XY bundle

Create array of these bundles

Create a cluster above this array

Add this cluster into an array

 

Feed this to the Plot

 

Conversion code for your case should look like this...

 

snippy.png

0 Kudos
Message 3 of 4
(2,547 Views)

Thank you for the response - I just realized that mistake right before I read your post and have redone it.  Here is the correct wayt to do it.  Now I have other errors to debug.  It never ends! 😛

 

usingPlotXYfixed_forsure.png

0 Kudos
Message 4 of 4
(2,543 Views)