Q:

Write a function myupp that will receive an integer argument n, and will return an n x n upper triangular matrix of random integers

0

Write a function myupp that will receive an integer argument n, and will return an n x n upper triangular matrix of random integers.

All Answers

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

myupp.m

function mat = myupp(n)

% Creates an n x n upper triangular matrix 

% of random integers

% Format of call: myupp(n)

% Returns upper triangular matrix

% Creates the matrix

mat = randi([-10,10],n,n);

% Programming method

for i = 1:n

 for j = 1:i-1

 mat(i,j) = 0;

 end

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