Cody

Problem 43573. Extract part elements of matrix into one new matrix

Created by Gareth Lee in Community

Given a matrix that includes different nonzero and zero entries, extract the nonzero elements and form a new matrix. The new matrix should maintain the same number of columns.

For example, for the input:

 a = [0 1 0; 1 0 2; 4 3 -5]

the output should be:

 [1 1 2; 4 3 -5]

Solution Stats

72.22% Correct | 27.78% Incorrect
Last solution submitted on Feb 08, 2019

Problem Comments

Recent Solvers12

Suggested Problems

More from this Author3