Write a function myupp that will receive an integer argument n, and will return an n x n upper triangular matrix of random integers
belongs to book: MATLAB: A Practical Introduction to Programming and Problem Solving|Stormy Attaway|Fourth Edition| Chapter number:14| Question number:31.14
All Answers
total answers (1)
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