개발자 뺚
[Cody] Problem 55220. Matrix Quadrants 본문
Write a function that takes N as the input, and outputs a matrix whose upper-left (NxN) quadrant contains all ones, the lower-right (NxN) quadrant contains all N's, and zeros everywhere else. For example, if N = 3:

function M = foursquare(N)
M = zeros(2 * N);
M(1:N, 1:N) = ones(N);
M(N + 1:2 * N, N + 1:2 * N) = N * ones(N);
end
'Solution > MATLAB' 카테고리의 다른 글
[Cody] Problem 2166. Concatenate a successive power matrix in a column matrix (0) | 2023.11.21 |
---|---|
[Cody] Problem 2017. Side of an equilateral triangle (0) | 2023.11.19 |
[Cody] Problem 790. Cody Computer Part 5 - Guess the Name of Cody Computer (0) | 2023.10.13 |
[Cody] Problem 44946. Solve a System of Linear Equations (0) | 2023.08.23 |
[Cody]Problem 44947. Find the Oldest Person in a Room (0) | 2023.08.23 |