Divide vectors of different lengths?

3 views (last 30 days)
Hi,
I have two vectors of different lengths where one vector A is a 2x1 matrix and vector B is a 1x491 matrix. I want to divide each element in A by the vector B so that I get C and it will be a 2x491 matrix. I am not sure on how to execute this so can anyone please advise?
I want it to look something like this: A=[a1 a2]', B=[b1,...,b491], C=A/B where C=[a1/b1,...,a1/b491 ; a2/b1,...,a2/b491]

Accepted Answer

Azzi Abdelmalek
Azzi Abdelmalek on 7 Mar 2014
Edited: Azzi Abdelmalek on 7 Mar 2014
a=[1 2]
b=[1 2 3 4]
out=bsxfun(@rdivide,a.',b)

More Answers (0)

Community Treasure Hunt

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

Start Hunting!