MATLAB: Multiplying all values and create a single matrix

matrixmultiplication

Hi guys,
Very new to Matlab. If i had for example, a variable Length and a variable Height, for values between 1m and 5m, and i wanted to create a matrix of (1×25), containing all the possible values. eg L*H hence, 1*1, 1*2, 1*3, 1*4, 1*5, 2*1, … etc. How would i code this?
Thanks

Best Answer

Here's one way:
H = 1:5;
L = 1:5;
LH = bsxfun(@times,H,L');
LH = LH(:)