How can I form a Hankel matrix for the following example?

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

 Accepted Answer

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

That 'permute' operation wasn't actually needed. You can do it this way instead:
T = reshape(R(:,:,p+q-1),m,n*(p+q-1));
H = zeros(m*p,n*q);
for k = 1:p
H((1:m)+m*(k-1),:) = T(:,(1:n*q)+n*(k-1));
end
Very good idea. Thank you so much for your nice comments. The first program works properly (permute operation) but the second program doesn't works. why? You can see the R array in the attached, where m =4, n=4, p=4, q=5 Thanks again :)
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.

Sign in to comment.

More Answers (0)

Categories

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!