rows = 10;for ii = 1 : rows for jj = 1 : ii b = jj; if ii <= jj fprintf('%d \n',b) else fprintf('%d ',b) end end endResult = 1 1 2 1 2 3 1 2 3 4 1 2 3 4 5 1 2 3 4 5 6 1 2 3 4 5 6 7 1 2 3 4 5 6 7 8 1 2 3 4 5 6 7 8 9 1 2 3 4 5 6 7 8 9 10
MATLAB: How to add zeros above the numbers I created with this code
table of values
Related Question
- How to filter a matrix
- How to change part of a matrix into zero
- Use fprintf to create a multiplication table.
- How to modify a matrix to change the entries >=0 and multiply it by 5 AND to change the entries <0 and add 2 to those entries
- How to count the total number of occurrences of each digit avoiding the first elements of each cell
- Finding matching rows in matrix for multiple points without a loop
Best Answer