Thread Subject: Arithmatic operation for different matrix dimension

Subject: Arithmatic operation for different matrix dimension

From: Tanvir

Date: 3 Sep, 2010 01:32:04

Message: 1 of 2

Hi, I am new in matlab and would like to do arithmatic operation for different matrix dimensions. For instance:
A = [1 2 3; 4 5 6;] (2x3 matrix)
B= [1; 2;] (2x1 matrix)
How can I multiply A*B?
Basically, I would like to get the result like this:
A*B = [1x1 2x1 3x1; 4x2 5x2 6x2;]

Subject: Arithmatic operation for different matrix dimension

From: someone

Date: 3 Sep, 2010 02:27:20

Message: 2 of 2

"Tanvir " <itanvir@live.com> wrote in message <i5pj6k$fsg$1@fred.mathworks.com>...
> Hi, I am new in matlab and would like to do arithmatic operation for different matrix dimensions. For instance:
> A = [1 2 3; 4 5 6;] (2x3 matrix)
> B= [1; 2;] (2x1 matrix)
> How can I multiply A*B?
> Basically, I would like to get the result like this:
> A*B = [1x1 2x1 3x1; 4x2 5x2 6x2;]

% Omit the trailing semicolons inside the brackets and try this:

A = [1 2 3; 4 5 6];

B= [1; 2];

C = bsxfun(@times,A,B)

C =

     1 2 3
     8 10 12

Tags for this Thread

Everyone's Tags:

Add a New Tag:

Separated by commas
Ex.: root locus, bode

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.

Tag Activity for This Thread
Tag Applied By Date/Time
bsxfun someone 2 Sep, 2010 22:29:17
rssFeed for this Thread

Contact us at files@mathworks.com