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

Matlab. 1. Generate a random vector with 20 elements, call the vector vec. Displ

ID: 3580984 • Letter: M

Question

Matlab.

1. Generate a random vector with 20 elements, call the vector vec. Display vec. Find the sum of all the elements (called sumval), the mean (calle dmeanval), and the standard deviation (called stdval ).

2. Generate a vector with values from 0 to 2and a step size of 0.1. Find the tangent of each entry in the vector and plot it. Make the title your name and label your x andy axis appropriately.

3. Generate a random 25x25 matrix with integer values from 1 to 100 called large matrix.

i. Find the mean of the 13th column, called largemean, and display the result.

ii. Find the maximum value of the 4 throw, called largemax, and display theresult.

Explanation / Answer

Question 1)

vec = rand(20,1);
disp(vec);
sumval = sum(vec);
fprintf('sum -> %f ',sumval);
dmeanval = mean(vec);
fprintf('mean -> %f ',dmeanval);
stdval = std(vec);
fprintf('Standard Deviation -> %f ',stdval);

% sample ouptut
% 0.810603
% 0.170211
% 0.428216
% 0.308714
% 0.760126
% 0.098482
% 0.100652
% 0.587034
% 0.928374
% 0.815618
% 0.330943
% 0.850643
% 0.931112
% 0.949168
% 0.510901
% 0.753278
% 0.035990
% 0.576730
% 0.474120
% 0.609440
%sum -> 11.030355   
%mean -> 0.551518   
%Standard Deviation -> 0.300018

Quesiton 3)

large = randi([1 100],25,25);
largemean = mean(large(1:end,13));
disp(largemean);
largemax = max(large(4,1:end));
disp(largemax);
% sample output
% 58.400
% 92