Problem 308. Matrix with different incremental runs

Given a vector of positive integers a (>=0); How does one create the matrix where the ith column contains the vector 1:a(i) possibly padded with zeros:

in->a = [3 2 4];

out->b = [1 1 1;2 2 2;3 0 3;0 0 4];

Solution Stats

75.56% Correct | 24.44% Incorrect
Last solution submitted on Jun 22, 2017

Problem Comments

Solution Comments

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!