Upper triangular matrix - MATLAB Cody - MATLAB Central

Problem 1882. Upper triangular matrix

Difficulty:Rate

Create a function to retrieve the upper triangular matrix of a matrix (without using tril). The matrix will always be square.

Example

If a =

     1     2     3     4
     5     6     7     8
     9    10    11    12
    13    14    15    16

then y =

     1     2     3     4
     0     6     7     8
     0     0    11    12
     0     0     0    16

Solution Stats

63.5% Correct | 36.5% Incorrect
Last Solution submitted on Jan 24, 2025

Solution Comments

Show comments
Why should you share code?
In a discussion on LInkedin about my recent blog post, Do these...
2
3

Problem Recent Solvers150

Suggested Problems

Problem Tags

Community Treasure Hunt

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

Start Hunting!