Question: Matlab code 4) Write a function leadzero(v) which takes as input a vector v and as output, c, returns the number of zeros at the
4) Write a function leadzero(v) which takes as input a vector v and as output, c, returns the number of zeros at the beginning of v (number of zero elements before any non-zero element). For example, for input (-5, 5, 11] the output would be 0. If the input is [0, 0, 3, 0, 0, 0], the output would be 2. If the input is [0, 0, 0, 0, 7, 4) the output would be 4. 5) Write a function countnon(A) which takes as input a matrix A and as output returns the number, c, of non-zero elements in A. For example, if the input is [1, 0, 3; 0, 0, 5], the output would be 3. If the input is [1, 2, 3; 4, 0, 6), the output would be 5
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
