Problem 413. Back to basics 23 - Triangular matrix
Solution Stats
Problem Comments
-
3 Comments
Your test suite doesn't really match the problem statement. The tests require matrices with *exactly* all elements abot the main diagonal to be 0 *and* all elements on or below the main diagonal to be 1.
Additional test cases have been added.
Running this on octave returns the correct results yet the page still says I'm wrong.
function y = triangMatrix(x)
for i=1:rows(x);
for j=1:columns(x);
if j>i;
x(i,j)=0;
else
endif
endfor
endfor
disp(x)
endfunction
Solution Comments
-
1 Comment
I copied this code from somewhere.
Problem Recent Solvers737
Suggested Problems
-
Remove all the words that end with "ain"
1661 Solvers
-
3313 Solvers
-
Find common elements in matrix rows
1858 Solvers
-
Reverse the elements of an array
774 Solvers
-
Switch matrix to a column vector
297 Solvers
More from this Author39
Problem Tags
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!