Cody

Problem 351. Back to basics 8 - Matrix Diagonals

Created by Alan Chalker in Community

Covering some basic topics I haven't seen elsewhere on Cody.

Given an input vector of numbers, output a square array with the vector as the main diagonal and all other elements = 0.

[1:4] ->
1 0 0 0
0 2 0 0
0 0 3 0
0 0 0 4

Solution Stats

74.52% Correct | 25.48% Incorrect
Last solution submitted on Feb 23, 2019

Problem Comments

Recent Solvers648

Suggested Problems

More from this Author39

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!