MATLAB: Divide vectors of different lengths

differentdivisionlengthvectors

Hi,
I have two vectors of different lengths where one vector A is a 2×1 matrix and vector B is a 1×491 matrix. I want to divide each element in A by the vector B so that I get C and it will be a 2×491 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]

Best Answer

a=[1 2]
b=[1 2 3 4]
out=bsxfun(@rdivide,a.',b)