How to perform matrix pencil operations on matlab? Is there a toolbox or a function?
26 views (last 30 days)
Show older comments
I need to perform matrix pencil operations but unable to find any function or toolbox that performs the same. Please help.
0 Comments
Answers (2)
Ced
on 16 Mar 2016
Edited: Ced
on 16 Mar 2016
Do you just need to evaluate a matrix pencil? You can just write your own little function.
Let's say you want to compute the pencil of degree l. This is one possible way of about doing it:
1. save the l+1 matrices in a big 3D matrix.
2. multiply each "plane" i (3rd dimension) with one pencil weight lambda i
3. sum it all up
Note: A more efficient way to do this would be to stack the matrices in columns (i.e. stay in 2D rather than 3D). If speed is not an issue, then I find the 3D version "safer" and clearer, but that's a personal choice.
Little dummy example:
Let's say l = 2 and A0,A1,A2 are nxn matrices. lambda is an (l+1)x1 vector.
M3D = cat(3,A0,A1,A2); % stack in 3rd dimension
% iterative way:
pencil_it = zeros(n,n);
for i = 1:l+1
pencil_it = pencil_it + lambda(i)*M3D(:,:,i);
end
% direct way:
% turn lambda in 3rd dimension, adjust it to size of matrices, multiply, sum up
pencil_direct = sum(M3D.*repmat(permute(lambda,2,3,1),n,n),3);
EDIT: Forgot to say:
The lambda vector can easily be obtained from your lambda weight by
lambda = lambda_weight.^(0:l)';
0 Comments
Matthew Wade
on 1 Aug 2020
Edited: Matthew Wade
on 1 Aug 2020
Typo in direct solution:
pencil_direct = sum(M3D.*repmat(permute(lambda,2,3,1),n,n),3);
should be square brackets in second argument for permute
pencil_direct = sum(M3D.*repmat(permute(lambda,[2,3,1]),n,n),3);
0 Comments
See Also
Categories
Find more on Linear Algebra 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!