How can I generate the Hankel matrix using the measured datapoints?

Dear Researchers, how can I generate a Hankel matrix based on the available data?
For instance, I have the measured data as y = [0 1 3 5 7; 0 2 4 6 8]; I want to generate the Hankel matrix as Y = [y(1) y(2) y(3) y(4); y(2) y(3) y(4) y(5)], where y(k) represents the measured data at k-th time instance, i.e. y(1) = [0; 0], so y(k) is a 2x1 column vector. So, I want to generate the Hankel matrix in which each element is a 2x1 column vector. In my case, I want to get this matrix Y = [0 1 3 5; 0 2 4 6; 1 3 5 7; 2 4 6 8]. This matrix y is taken just for demonstration purpose. It would be better if you suggest solution for high dimension data matrix. This help will be valuable for me! Thanks!

 채택된 답변

Ameer Hamza
Ameer Hamza 2020년 12월 27일
Try something like this
y = [0 1 3 5 7; 0 2 4 6 8];
k = 2; % Y rows in output matrix
[m, n] = size(y);
i = hankel(1:n);
i = i(1:k, 1:end-1);
Y = reshape(y(:,i), m*k, [])

댓글 수: 4

Dear Ameer, thank you for your answer, It gives me the same solution as I want, but what is the k in this code? In my case k is the time instant.
In my code, k is number of rows in this form of matrix Y: Y = [y(1) y(2) y(3) y(4); y(2) y(3) y(4) y(5)]. Use some other name instead of 'k' if it conflict it with a variable in your code.
Dear Ameer, thanks for your help. It works now. Wish you best!
I am glad to be of help!

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

도움말 센터File Exchange에서 Random Number Generation에 대해 자세히 알아보기

질문:

2020년 12월 27일

댓글:

2020년 12월 31일

Community Treasure Hunt

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

Start Hunting!

Translated by