'Concatenating the output of a for loop

Y= zeros(3, 354)
    for m = 1 : 118
        R=GridData.R2(:,3*m-2:3*m);
        X=GridData.X2(:,3*m-2:3*m);
        B=GridData.B1(:,3*m-2:3*m);
        G=GridData.G1(:,3*m-2:3*m);
        Y(:,m)= R+ 1j*X;
        m=m+1;
    end

This is the error: Index in position 2 exceeds array bounds (must not exceed 3). I would like to concatenate the output from a for loop.



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source