matrix repetition on diagonal
古いコメントを表示
Hi, I have a matrix
T =
1 0
1 1
and i want to generate this matrix
T =
1 0 0 0
1 1 0 0
0 1 1 0
0 0 1 1
please note that T is not exactly repeating at diagonal. Can anyone help me with this ? thank you
採用された回答
その他の回答 (2 件)
Stephen23
2017 年 9 月 7 日
I suspect you might want something like this:
>> T = [1,0;1,1];
>> N = 4;
>> R = zeros(1,N);
>> C = zeros(1,N);
>> R(1:size(T,1)) = T(:,1);
>> C(1:size(T,2)) = T(1,:);
>> toeplitz(R,C)
ans =
1 0 0 0
1 1 0 0
0 1 1 0
0 0 1 1
>>
but without a clear explanation of the algorithm that generates the output matrix from the input matrix, this is just a guess.
KSSV
2017 年 9 月 7 日
T = ones(4,1) ;
K = diag(T)+diag(T(1:end-1),-1)
カテゴリ
ヘルプ センター および File Exchange で Operating on Diagonal Matrices についてさらに検索
製品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!