Devision of matrix by matrix

1 view (last 30 days)
Scragmore on 21 Oct 2011
Hi, Please excuse total n00b here.
I am after devision of matrix by a second matrix, example;
x = [4; 8; 12; 16; 20];
y = [2 4];
I want x/y to give
ans = [2 1; 4 2; 6 3; 8 4; 10 5]

Accepted Answer

the cyclist
the cyclist on 21 Oct 2011
The bsxfun() command will automatically replicate arrays across the dimensions you need:
I recommend reading "doc bsxfun" to get an understanding of the function.

Sign in to comment.

More Answers (0)


Find more on Resizing and Reshaping Matrices in Help Center and File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!