Turn on suggestions

Auto-suggest helps you quickly narrow down your search results by suggesting possible matches as you type.

Showing results for

- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Mute
- Printer Friendly Page

04-19-2011 10:24 AM

Options

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report to a Moderator

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

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report to a Moderator

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

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report to a Moderator

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

Solution

Accepted by topic author Canalian

04-19-2011 06:52 PM - edited 04-19-2011 06:54 PM

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report to a Moderator

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

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report to a Moderator

Thanks that is really appreciated

Regards

Nick