ni.com is currently undergoing scheduled maintenance.

Some services may be unavailable at this time. Please contact us for help or try again later.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Covariance VI

Hi,

 

We're trying to create a covariance matrix out of measurements of x,y coordinates (covariance between x and y). In order to do so, as we understand we should enter the VI a 2-d vector of samples of x,y and the vi creates the covariance matrix. Our question is- Is there a way to do this without saving the previous 20 (for example) samples in a shift register and just enter 1 sample at a time?

 

Thanks.

 

Rap Master

 

 

0 Kudos
Message 1 of 4
(3,292 Views)

Hey Rap Master,

 

Do you mean enter a single (x,y) pair into Covariance Matrix.vi, and then repeat this for other samples? You won't get a meaningful result from a single pair - for a two dimensional variation you need at least a 2x2 matrix to characterize it. You should build your set of samples into an array and then use that as your input to the Covariance Matrix.vi. Does that provide some clarity?

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

I understand that, I'll try to be more clear.

 

My goal is to get the covariance between a robot's coordinates (x,y). I'm running a loop and every iteration I get new coordinates for the robot's localization. In order to calculate the covariance I want to use Covariance VI which indeed needs 2 vectors for x & y. I'm not sure how many samples of x,y I need in order to get a good result and if I have to use some kind of shift register to save the previous samples or is that something which the VI can do. From your answer I understand it doesn't. Am I correct?

 

Thanks,

 

Tomer

 

0 Kudos
Message 3 of 4
(3,266 Views)

Tomer,

 

A shift regsiter is a good way to pass data from one iteration to the next.  You can certainly accumulate your arrays in shift registers.

 

The major problem with building an array in a shift register is that it must continually re-allocate memory for the array. All the elements of an array must be stored in contiguous memory locations.  If the array can get large, it is better to initialize the array to the maximum size outside the array and then use Replace Array Subset inside the loop to put the data into the array.

 

I am not sure what the Covariance calculation will do with the initialized values in the array.  You may need to use Array Subset and only apply the covariance calculation to the part of the array with actual data in it.

 

Lynn

0 Kudos
Message 4 of 4
(3,258 Views)