Q:

Write a function numbers that will create a matrix in which every element stores the same number num. Either two or three arguments will be passed to the function

0

 Write a function numbers that will create a matrix in which every element stores the same number num. Either two or three arguments will be passed to the function. The first argument will always be the number num. If there are two arguments, the second will be the size of the resulting square (n x n) matrix. If there are three arguments, the second and third will be the number of rows and columns of the resulting matrix. 

All Answers

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

numbers.m

function outmat = numbers(num,varargin)

if nargin == 2

 outmat = ones(varargin{1}) * num;

else

 outmat = ones(varargin{1},varargin{2}) * num;

end

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