Repeat element in an array and add behind it

this is a loop in my script:

for k=1:K
    block= squeeze(Data_orig(k,:,:)); % K x M x N
    a=2;
    for dd=1:d
        for w=(a*dd-(a-1)):(a*dd)
             % `mtxr` is P x M x N/a.
            data(:,w)=mtxr(:,:,dd)*block(:,w);  % M x N 
        end
    end
    mtxr_tr(:,:,k)=data.'; % (N x M x K)
end

Let me explain this loop. [example] data(:,w)=mtxr(:,:,dd)*block(:,w);

  • mtxr= [ a1, a2, a3], where a1, a2, a3 are arrays

  • block= [ b1, b2, b3, b4, b5, b6], where b1, ...b5 are arrays

  • Result data :

1) a1 * b1

2) a1 * b2

3) a2 * b3

4) a2 * b4

5) a3 * b5

6) `a3 * b6'

I would like to create an array B as a1 a1 a2 a2 a3 a3. B is constructed from mtxr, but every element is copied and added behind. How can I create the array B?