フィルターのクリア

Is there a function that populates a matrix whose minor diagonal are all the same?

4 ビュー (過去 30 日間)
zzzhhh
zzzhhh 2018 年 10 月 18 日
コメント済み: zzzhhh 2018 年 10 月 18 日
Is there a function that populates a matrix whose minor diagonal are all the same, according to the given (odd-numbered) vector? For example, for
[1, 7.9, 100, 18.2, -3.4]
, we can get a 3x3 matrix:
1 7.9 100
7.9 100 18.2
100 18.2 -3.4
I can of course populate this matrix myself. I am just wondering if there is a single function provided by Matlab that can do it. Thanks.

採用された回答

Stephen23
Stephen23 2018 年 10 月 18 日
編集済み: Stephen23 2018 年 10 月 18 日
Use hankel:
>> V = [1,7.9,100,18.2,-3.4];
>> hankel(V(1:3),V(3:end))
ans =
1 7.9 100
7.9 100 18.2
100 18.2 -3.4
You can easily calculate the midpoint index:
N = (1+numel(V))/2;
hankel(V(1:N),V(N:end))

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeMultidimensional Arrays についてさらに検索

製品

Community Treasure Hunt

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

Start Hunting!

Translated by