main.m385 chars17 lines
This code first initializes a 5 by 3 matrix M
with zeros. Then it uses a nested for loop to initialize and double the values in each column. The outer for loop iterates over the columns from 1 to 3, and the inner for loop iterates over the rows from 2 to 5.
In each iteration of the outer loop, the first element in the current column is initialized to the current column number (i.e. 1, 2 or 3). Then in each iteration of the inner loop, the current element in the current column is set to be twice the previous element in that column.
Finally, the resulting matrix M
is displayed using the disp
function.
gistlibby LogSnag