フィルターのクリア

How to directly create a non-random upper or lower triangle matrix without creating a full square matrix?

4 ビュー (過去 30 日間)
I want to create the upper triangle matrix only directly in matlab and reflect it to make a full square matrix. I will assign numerical values to all the variables listed in the matrix.

回答 (1 件)

Rishabh Mishra
Rishabh Mishra 2020 年 11 月 4 日
編集済み: Rishabh Mishra 2020 年 11 月 4 日
Hi,
Consider the upper triangular matrix created below:
A = [1 2 3 4; 0 5 6 7; 0 0 8 9; 0 0 0 10];
To create the mirror image of upper triangle into the lower triangle, use the code below:
for i = 1:size(A,1)
for j = 1:size(A,1)
if j < i
A(i,j) = A(j,i);
end
end
end
Hope This helps.
  2 件のコメント
Raghu Echempati
Raghu Echempati 2020 年 11 月 5 日
Thanks. But I do not want to type in zeros for A. If I create a null (6,6) or zeros(6) matrix, how do I just add the upper triangle coeffients to the null matrix? That makes it easy for me not to type the zeros to define matrix A. Thanks.
E.
Raghu Echempati
Raghu Echempati 2020 年 11 月 9 日
I hope you understood my question. How can I just create the elements (cofficients) of an upper or lower triangle matrix without adding zeros to make it a squre matrix?

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

カテゴリ

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

製品


リリース

R2019b

Community Treasure Hunt

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

Start Hunting!

Translated by