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:
Substraction between two matix with different dimension

Subject: Substraction between two matix with different dimension

From: Jamal

Date: 11 May, 2013 11:00:07

Message: 1 of 2

Dear all

I have 2 matix which has dimension;
1. (911 x 38)
2. (911 x 2)

Both matrix has constant values at first column.
I would like to substract the values of the rest of the column in 1st matrix (2nd - 37th column) with the 2nd column value from the 2nd matrix.

could somebody show me detail operational command in the matlab?

Thanks

Subject: Substraction between two matix with different dimension

From: James Tursa

Date: 11 May, 2013 17:41:07

Message: 2 of 2

"Jamal" wrote in message <kml8bn$c49$1@newscl01ah.mathworks.com>...
> Dear all
>
> I have 2 matix which has dimension;
> 1. (911 x 38)
> 2. (911 x 2)
>
> Both matrix has constant values at first column.
> I would like to substract the values of the rest of the column in 1st matrix (2nd - 37th column) with the 2nd column value from the 2nd matrix.

A = rand(911,38);
B = rand(911,2);
A(:,2:38) = bsxfun(@minus,A(:,2:38),B(:,2));

James Tursa

Tags for this Thread

No tags are associated with 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