Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function [matrix_out] = MxN_matrix(row,column)
- % FUNCTION: Makes a matrix where each cell is equal to its row
- % multiplied by its column
- %
- % INPUTS:
- % 1) row: The amount of rows the matrix will have.
- % 2) column: The amount of columns the matrix will have.
- %
- % OUTPUTS:
- % 1) matrix_out: The final calculated matrix.
- %Checks if row or column is negative or 0.
- if row <= 0 || column <= 0
- new_matrix = 0;
- %If row and column are non-zero and positive.
- else
- %For loop counts from 1 to the user's amount of columns.
- for count_column = 1:1:column
- %For loop counts from 1 to the user's amount of rows.
- for count_row = 1:1:row
- %Updates the matrix with the row * column calculation for every
- %row and column.
- matrix_out(count_row,count_column) = (count_row * count_column);
- end %For (row) end
- end %For (column) end
- end %If (checking) end
Advertisement
Add Comment
Please, Sign In to add comment