Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

Thread Subject:
How to normalize and expand the elements in the matrix

Subject: How to normalize and expand the elements in the matrix

From: Hero Lee

Date: 7 Dec, 2009 12:35:04

Message: 1 of 2

Dear Sir or Madam,

Good morning, I've two questions about the operation of the matrix, and do wish you can kindly solve which for me.

1. The first question is about normalizing the elements in the matrix.
There is a matrix A, and I would like to normalize the elements in A.
By other means, the sum of each row in A is equivalent to 1.0.

For example;
A is a 2X3 matrix,
A=[0.2 ,0.8, 0.3; 0.2, 0.4, 0.4]
And I hope it'll be normalized to
B=[0.2/(0.2+0.8+0.3), 0.8/(0.2+0.8+0.3), 0.3/(0.2+0.8+0.3);
     0.2/(0.2+0.4+0.4), 0.4/(0.2+0.4+0.4), 0.4/(0.2+0.4+0.4)]

How can I get the matrix B? Thank you.

2. The second question is about expanding the multiply operation of two matrices.
There are two matrices A and B, and I would like to expand these two matrices by
the multiply operation.

For example;
A and B are 2X3 matrices both,
A=[a1, a2, a3; a4, a5, a6], B=[b1, b2, b3; b4, b5, b6]
And I hope it'll be multiplied to a 2x9 matrix, such as
A x B= [a1*b1, a1*b2, a1*b3, a2*b1, a2*b2, a2*b3, a3*b1, a3*b2, a3*b3;
           a4*b4, a4*b5, a4*b6, a5*b4, a5*b5, a5*b6, a6*b4, a6*b5, a6*b6]

How can I get the matrix AxB? Thank you.

Really thank you so much.
 

Subject: How to normalize and expand the elements in the matrix

From: Joe Tomaino

Date: 5 Jan, 2010 00:14:05

Message: 2 of 2

Here's a simple and (I hope) elegant solution to problem #1:

A = [.1 .8 .3; .2 .4 .4]
Temp1 = sum(A,2)
Temp2 = repmat(Temp1,1,size(A,2))
B = A./Temp2
sum(B,2)

That should do it. Good luck with problem #2, I'll let you know if I think of anything.

-Joe

Tags for this Thread

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

Contact us