Search All of the Math Forum:

Views expressed in these public forums are not endorsed by NCTM or The Math Forum.

Topic: Comparing individual cells of matrix with another matrix
Replies: 6   Last Post: Apr 9, 2013 12:57 PM

 Messages: [ Previous | Next ]
 dpb Posts: 9,850 Registered: 6/7/07
Re: Comparing individual cells of matrix with another matrix
Posted: Apr 8, 2013 6:51 PM

On 4/8/2013 5:47 PM, Avni wrote:
> I have a matrix A which is a 20 by 40 and matrix B which is 20 by 55. I
> am trying to divide each cell with matrix A with each cell in Matrix B
> to create a new matrix C. However, I am not trying to use loops because
> the program will take forever to run. I tried looking in to the bsxfun
> function however, it says i need both matrixes to be the same dimensions
> and I repmat does not really work.
> there any other functions that I could use that I over looked?

Well, what do you think should happen for the extra 15 columns of B that
aren't in A?

C=A./B(1:size(A,1),1:size(A,2));

is one solution if size(A) is always < size(B); otherwise you would have
to pick min() of both.

--

Date Subject Author
4/8/13 Guest
4/8/13 dpb
4/8/13 Guest
4/8/13 dpb
4/8/13 Roger Stafford
4/9/13 Bruno Luong
4/9/13 Roger Stafford