From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.
We appreciate your patience as we improve our online experience.
From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.
We appreciate your patience as we improve our online experience.
04-19-2011 10:24 AM
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
Solved! Go to Solution.
04-19-2011 11:52 AM
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
04-19-2011 06:35 PM
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
04-19-2011 06:52 PM - edited 04-19-2011 06:54 PM
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):
04-19-2011 07:01 PM
Thanks that is really appreciated
Regards
Nick