Q:

Write a function that receives a matrix as an input argument, and prints a random row from the matrix

0

 Write a function that receives a matrix as an input argument, and prints a random row from the matrix.

All Answers

need an explanation for this answer? contact us directly to get an explanation for this answer

printRanRow.m

function printRanRow(mat)

% Prints a random row from a matrix

% Assumes a fairly small matrix of ints

% Format of call: printRanRow(matrix)

% Does not return any values

[r c] = size(mat);

ranrow = randi([1,r]);

fprintf('%d ', mat(ranrow,:))

fprintf('\n')

end

need an explanation for this answer? contact us directly to get an explanation for this answer

total answers (1)

Similar questions


need a help?


find thousands of online teachers now