 <ol> <li><p>Use repmat in order to concat 3 copies of your matrix horizontally.</p></li> <li><p>Use the Matlab's assignment syntax: A(row,col:col+length(x)-1) in order to copy x into the desired row and col.</p></li> </ol> <p>Code example:</p> <pre><code>outA = repmat(A,1,3); %replicate A outA(2,1:length(x)) = x; %inserts x into the beginning of the 2nd row outA(4,size(outA,2)-length(x)+1:end) = x; %inserts x into the end of the 4th row </code></pre> <p>Results:</p> <pre><code>outA = 1.1 2.2 3.1 4.1 5.3 1.2 1.3 1.1 2.2 3.1 4.1 5.3 1.2 1.3 1.1 2.2 3.1 4.1 5.3 1.2 1.3 1.0 2.0 3.0 4.0 5.0 6.0 7.0 3.1 4.2 1.1 7.4 5.6 2.2 1.3 3.1 4.2 1.1 7.4 5.6 2.2 1.3 1.4 5.2 4.3 2.2 4.3 3.2 1.3 1.4 5.2 4.3 2.2 4.3 3.2 1.3 1.4 5.2 4.3 2.2 4.3 3.2 1.3 1.6 3.2 6.3 2.1 2.6 7.2 1.3 1.6 3.2 6.3 2.1 2.6 7.2 1.3 1.0 2.0 3.0 4.0 5.0 6.0 7.0 6.1 1.3 9.4 4.2 3.3 1.2 1.3 6.1 1.3 9.4 4.2 3.3 1.2 1.3 6.1 1.3 9.4 4.2 3.3 1.2 1.3 2.5 4.2 3.2 5.1 6.7 1.2 1.3 2.5 4.2 3.2 5.1 6.7 1.2 1.3 2.5 4.2 3.2 5.1 6.7 1.2 1.3 </code></pre>