How is the 2D filter function used in this code?
이전 댓글 표시
In one of the cody answers (solution 712713), I found a following code:
function B = hanlelize(A)
F = flip(eye(111));
B1 = filter2(F,A);
B2 = filter2(F,A|1);
B = B1./B2;
end
This function convert an input matrix A to a Hankel matrix B by replacing each skew-diagonal of A with its mean. For example, if the input is
A =
3 7 10 2
3 5 1 2
6 3 2 7
then, the matrix B1, B2, B will be
B1 =
3 10 21 6
10 21 6 4
21 6 4 7
B2 =
1 2 3 3
2 3 3 2
3 3 2 1
B =
3 5 7 2
5 7 2 2
7 2 2 7
The code looks elegant but I'm not so familiar with the 2D filter function used in this code.
- How is the 2D filter working in the computation of B1? Why does the 2D filter by flipped identity matrix result in B1?
- How is the 2D filter working in the computation of B2? What does 'A|1' mean? I checked the documentation of filter2 but I couldn't find such an expression.
I'm looking forward to your help.
채택된 답변
추가 답변 (0개)
카테고리
도움말 센터 및 File Exchange에서 Images에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!