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 Exchange에서 Creating 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