Find last zero for each column - MATLAB Cody - MATLAB Central

Problem 1699. Find last zero for each column

Difficulty:Rate

Given a numeric array of arbitrary size, return the row index of the last zero for each column. If a column contains all nonzero values, return 0 for that column. Your output should be a row vector.

Example

a = [0 0 9 0;
     0 0 1 8;
     0 0 4 0;
     0 0 2 3;
     0 6 7 5];
z = [5 4 0 3]

Solution Stats

44.12% Correct | 55.88% Incorrect
Last Solution submitted on Mar 14, 2025

Problem Comments

Solution Comments

Show comments
Who Deserves Your Praise? Discover the New Contribution Widget!
...
We are excited to announce another update to our Discussions area: the...

Problem Recent Solvers591

Community Treasure Hunt

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

Start Hunting!
Go to top of page