Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

6:49 PM University of Houston .11 Sprint Wi-Fi 16 of 91 2.5 Questions a. Create

ID: 3283004 • Letter: 6

Question

6:49 PM University of Houston .11 Sprint Wi-Fi 16 of 91 2.5 Questions a. Create a random integer matrix A of size 4x4 taking values from 5 to 15 and display it using the MATLAB function disp b. Slioe row 1 of matrix A and store it in a variable rou1 then display it using disp. c. Slice row 4 and store it in a variable roud then display it using disp. . Add row1 and ro2 and store this sum in a new variable sunrow then display it us- ing disp. e. Create a new variable called sunroul such that it contains the sun of the entries of rou1. Display a message using the MATLAB function fprintf that reads The sm of entries in rowl is where in place of *you will have a number that is equal to the sm. f. Slice co 2 of matrix A and store it in a variable col2 then display it using disp. Slice con 3 of matrix A and store it in a variable co13 then display it using disp h. Add co12 and co13 and store this sum in a new variable suncol then display it us- ing disp. i. Create a variable called sunco12 such that it contains the sum of the entries of co12. Display a message using the MATLAB function fprintf that reads The sum of entries in col2 is where in place of you will have a number that is equal to the sum a. Create a diagonal matrix from the diagonal entries of matrix A and display it in the command window b. Take the transpose of matrix A and display it in the commmand window c. Create an upper triangular matrix froa the values of matrix A by using the MAT LAB function triu. Display this in the command windom d. Create a lower triangular matrix from the values of matrix A by using the MATLAB 15

Explanation / Answer

%answer a
a=5;b=15;
A=a+((b-a).*rand(4));
disp(A)

%answer b
row1=A(1,:);
disp(row1)

%answer c
row4=A(4,:);
disp(row4)

%answer d
sumrow= sum(row1+A(2,:));
disp(sumrow)

%answer e
sumrow1=sum(row1);
fprintf('The sum of entries in row1 is : %d . ',sumrow1)

%answer f
col2= A(:,2);
disp(col2)

%answer g
col3= A(:,3);
disp(col3)

%answer h
sumcol=col3+col3;
disp(sumcol)

%answer i
sumcol2=sum(col2);
fprintf('The sum of entries in col2 is : %d . ',sumcol2)