MATLAB: Substitute each element of a vector into a matrix without using loop

arrayloopmatrixvector

Hi I want to substitute each element of vector1 into 'x' in matrix1 and store each matrix in an array without using a loop. Please tell me how.
vector1=[1:1:10];
matrix1=[4*x 5*x ; 4*x 2*x];
Thanks in advance.

Best Answer

Like this?
vector = 1:1:10;
vector = reshape( vector, [1, 1, numel(vector)] );
one_vector = ones( 1, 1, numel(vector) );
matrix = [4 * vector, 5 * one_vector; 4 * one_vector, 2 * vector ];