개발자 뺚

[Cody] Problem 2166. Concatenate a successive power matrix in a column matrix 본문

Solution/MATLAB

[Cody] Problem 2166. Concatenate a successive power matrix in a column matrix

2023. 11. 21. 15:00
Generate F = [M1 M^2 ... M^p] with M a matrix, without using for.

function F = powerConcat(M,p)

    F = M;
    for i = 2:p
        F = cat(2, F, M^i);
    end
end