Matlab Code Create a 5 column and 4 row matrix of random num

Matlab Code: Create a 5 column and 4 row matrix of random numbers bounded between 0 and 5. Call this r_matrix.

1. Find the largest single element in the matrix

2. Find the sum of each column of the matrix

3. Find the sum of each row of the matrix

Solution

Matrix creation 5X4 is

a = 0;// starting range

b = 5;// end rang

for i=1:5

for j=1:4

m(i,j)= a + (b-a).*rand(1);;

end;

end;

Here matrix created 5x4 ;

1> Now find max value in matrix

max=0;

for i=1:5

for j=1:4

if(max<m(i,j))

max=m(i,j);

end;end;end;

disp(\"Largest value in matrix is: \");disp(max);

2 sum of each column of matrix is sum_column=sum(m,1);

and dispaly the sum is disp(sum_column);

3> sum of each row of matrix is sum_row=sum(m,2);

and dispaly the sum is disp(sum_row);

Matlab Code: Create a 5 column and 4 row matrix of random numbers bounded between 0 and 5. Call this r_matrix. 1. Find the largest single element in the matrix

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site