How can I form a Hankel matrix for the following example?
5 views (last 30 days)
Show older comments
I have 6 separate matrix like R(:,:,1) R(:,:,2) R(:,:,3) R(:,:,4) R(:,:,5) R(:,:,6). Each R contains a 4x4 matrix. for example R(:,:,1)= [0.0479 0.0987 0.1126 -0.0126; 0.0547 0.1128 0.1287 -0.0144; 0.1093 0.2254 0.2573 -0.0288; -0.0118 -0.0243 -0.0278 0.0031]. Now, I want to make a Matrix like H: for p=3 & q=4 where,
H= [R1 R2 R3 Rq;
R2 R3 R4 R(q+1);
Rp R4 R5 R(q+2)]
Here R1=R(:,:,1),R2=R(:,:,2)...so on
*My question:* How can I make H matrix by matlab program if I want to change for p & q like p=6 & q =7 etc.?
Thanks in advance... D. Bhuiyan
0 Comments
Accepted Answer
Roger Stafford
on 11 Dec 2014
Let R be an m x n x r array in which r >= p+q-1 using your definition for p and q. Then do this:
T = reshape(permute(R(:,:,1:p+q-1),[1,3,2]),m*(p+q-1),n);
H = zeros(p*m,q*n);
for k = 1:q
H(:,(k-1)*n+1:k*n) = T((1:p*m)+(k-1)*m,:);
end
4 Comments
Roger Stafford
on 11 Dec 2014
I see why the second version doesn't work. It should have been written this way:
T = reshape(R(:,:,1:p+q-1),m,n*(p+q-1)); % <-- Corrected
H = zeros(m*p,n*q);
for k = 1:p
H((1:m)+m*(k-1),:) = T(:,(1:n*q)+n*(k-1));
end
Sorry about that.
More Answers (0)
See Also
Categories
Find more on Resizing and Reshaping 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!