Cody

Problem 1704. Triangular matrices in 3D array

Given a 3D numeric array x, return an array y of the same size in which all entries to the right of the main diagonal are zero for y(:,:,i).

Example

If

x(:,:,1) = 1 2 3
           4 5 6
           7 8 9
x(:,:,2) = 1 4 7
           2 5 8
           3 6 9
x(:,:,3) = 1 2 3
           1 2 3
           1 2 3

then

y(:,:,1) = 1 0 0
           4 5 0
           7 8 9
y(:,:,2) = 1 0 0
           2 5 0
           3 6 9
y(:,:,3) = 1 0 0
           1 2 0
           1 2 3

Solution Stats

69.23% Correct | 30.77% Incorrect
Last solution submitted on Mar 30, 2016
Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

MATLAB Academy

New to MATLAB?

Learn MATLAB today!

Join the 15-year community celebration.

Play games and win prizes!

Learn more