フィルターのクリア

n number of 2x2 matricies to diagonal matrix

4 ビュー (過去 30 日間)
k
k 2020 年 3 月 29 日
コメント済み: k 2020 年 3 月 29 日
I have a 2x2 matrix that I need put into the diagonal of a matrix n times. In other words, on each diagonal, a new 2x2 matrix prints. For cells with two k values, they should be added together.
For example:
n = 3:
k -k 0 0
-k k+k -k 0
0 -k k+k -k
0 0 -k k
What I have:
n = input('Input the number of elements:');
k = ((E * avg_area)/L)*[+1 -1; -1 +1];
for n;
k_global = diag(k);
end

採用された回答

David Hill
David Hill 2020 年 3 月 29 日
n = input('Input the number of elements:');
k = ((E * avg_area)/L);
k_global=diag([k,repmat(k+k,1,n-1),k])+diag(repmat(-k,1,n),-1)+diag(repmat(-k,1,n),1);
  1 件のコメント
k
k 2020 年 3 月 29 日
Thank you so much!

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeOperating on Diagonal Matrices についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by