Creating an augmented matrix a set of matrices
Show older comments
Hi all,
I'm writing some code and feel like there should be a way to do this better but I am not sure how.
I want to produce a finite termination of this:

from an
matrix A where
are
matrices.
For example, I might want to make

with
.
.So far I've succefully done this with a loop. Is there a way to do it via vectorisation?
Thank you for your advice :-)
Here's my draft attempts. s tells me how many rows I want, I also do not know what k is before I start. The augmented matrix in the literature tends to be written as 𝒜hence me calling it "curlyA".
A(:,:, 1) = [1, 3; 0 1]; A(:,:, 2) = [1, 1; 1 1]; %A(:,:, 3) = [0, 0; 0 0];
[n, ~, k] = size(A);
s = 2;
curlyA = zeros(n*(s+1)); % construct augmented curly A
max_col = reshape(permute(A(:,:, 1:k),[2 1 3]),size(A,2),[])'; % make first column of curly A for this order pole
if k < size(curlyA, 1)
max_col(size(curlyA, 1), n) = 0; % if we don't have enough rows, add zeros
end
for ii = 1:s+1
curlyA((ii-1)*n+1:end, (ii-1)*n+1:ii*n) = max_col(1:((s+1)-ii+1)*n, :); % construct curly A from max_col
end
Accepted Answer
More Answers (0)
Categories
Find more on Creating and Concatenating Matrices in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!