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

The following exercises are meant to be answered by few lines of MATLAB code; mo

ID: 3804621 • Letter: T

Question

The following exercises are meant to be answered by few lines of MATLAB code; most of them could be expressed in a single line of code or command. The command may be involved (i.e., it may use a number of parentheses or calls to functions) but can, in essence, be solved by the execution of a single command. If the problem is too complicated, feel free to break it up over two or more lines and later to collapse it into a single line.

7. Matrix operations:

a. Create a random 3x4 matrix A of numbers in the range 10 to 50:

s=10;

f=50;

rand('seed',123965);

A=reshape((f-s)*rand(1,12)+s,3,4);

b. Create a random 4x5 matrix B of integers in the range 20 to 20:

s=20;

f=20;

B=reshape(round((f-s)*rand(1,20)+s),4,5)

c. Compute the average X of all the elements of the matrix C=A*B.

d. Find the largest element in the 2nd row of matrix C.

e. Find the (row,column) coordinate of the smallest element in the matrix C.

Explanation / Answer

c.

C=A*B;

X = mean(C(:))

d.

M = max(C(2,:),[],2)

e.

[M,I] = min(C(:));
[I_row, I_col] = ind2sub(size(C),I)

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote