LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Subtract the mean of a matrix from each element

Solved!
Go to solution

Hi,

 

I am doing principle component analysis I have an original real matrix feeding in to a the covarience matrix which gives the mean out at one of the nodes and want to subtract that from each element of the original matrix to form a new matrix. If this is to hard to connect the mean out of the covariance matrix is there a way of just finding the mean of the original matrix and subtracting this from each element in the matrix to form a new matrix.

 

Thanks for your help

 

Regards

Canalian

0 Kudos
Message 1 of 5
(1,425 Views)

The Subtract primitive on the Numeric palette is polymorphic.  You can subtract a scalar from a matrix or an array.  The result is also a matrix or an array with the scalar value subtracted from each element.

 

Lynn

0 Kudos
Message 2 of 5
(1,413 Views)

Hi Lynn,

 

Thanks for your quick reply. I must have been tired last night I realised that the problem is that I have a 1d matrix comming out of the covariance matrix and I am trying to subtract that from a each element of a 2d matrix, but I don know how to do this. I have attached the code of what I am trying showin the broken wire.

 

Your help is greatly appreciated.

 

Regards

Nick

0 Kudos
Message 3 of 5
(1,401 Views)
Solution
Accepted by topic author Canalian

The mean of a 2D array is simply the sum of all elements divided by the number of elements (=the product of the dimensions).

 

All you need is the following (works equally well for arrays with more than 2 dimensions):

 


LabVIEW Champion. It all comes together in GCentral GCentral
Message 4 of 5
(1,396 Views)

Thanks that is really appreciated

 

Regards

 

Nick

0 Kudos
Message 5 of 5
(1,389 Views)