Hello please help me I need a answer this question.
Write separately the following patterns (a), (b) the MATLAB program codes that can be created for any N value entered by the user, given as an example for the n= 6 value.

回答 (1 件)

DGM
DGM 2021 年 6 月 2 日

0 投票

This is one way
n = 6;
A = diag(1:n)
A = 6×6
1 0 0 0 0 0 0 2 0 0 0 0 0 0 3 0 0 0 0 0 0 4 0 0 0 0 0 0 5 0 0 0 0 0 0 6
[bx by] = meshgrid(n:-1:1);
B = triu(by) + tril(bx,-1)
B = 6×6
6 6 6 6 6 6 6 5 5 5 5 5 6 5 4 4 4 4 6 5 4 3 3 3 6 5 4 3 2 2 6 5 4 3 2 1

カテゴリ

ヘルプ センター および File ExchangeCreating and Concatenating Matrices についてさらに検索

製品

質問済み:

2021 年 6 月 2 日

回答済み:

DGM
2021 年 6 月 2 日

Community Treasure Hunt

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

Start Hunting!

Translated by