I just need help on part 3 of the standard deviation 2. Give the following comma
ID: 2081454 • Letter: I
Question
I just need help on part 3 of the standard deviation 2. Give the following commands to create a matrix called F: randn('seed', 123456789) F randn(5,10); Note: MATLAB has functions min, max, mean(average), median and sum built-in. The questions that follow ask you to write your own code for these functions, as if they were not built-in. The idea here is for you to get some programming experience with MATLAB I. Compute the minimum and maximum value of each column and assign the results to the elements of a vector called min value and max value respectively. ll. Compute the mean of each column and assignthe results to the elements of a vector called avg. Ill. Compute the standard deviation of each column and assign the results to the elements of a vector called s. with X the current element, M the mean and n the number n-1 of elements In each case, you can check your results with the built-in functions.Explanation / Answer
Matlab Script:
randn('seed',123456789);
F = randn(5,10);
for i=1:10
meanmat(i) = mean(F(:,i));
end
for i=1:10
sum = 0;
for j=1:5
sum = sum+((F(j,i)-meanmat(i))^2);
end
std1(i) = sqrt(sum/(5-1));
end
disp('Standard deviation of each column:');
disp(std1);
command window output:
>> clear all
Standard deviation of each column:
Columns 1 through 4
1.2131 0.7533 0.3313 0.5499
Columns 5 through 8
0.7748 0.9208 1.1053 1.0867
Columns 9 through 10
0.6738 0.9204
>>
%built-in function result
>> std(F)
ans =
Columns 1 through 4
1.2131 0.7533 0.3313 0.5499
Columns 5 through 8
0.7748 0.9208 1.1053 1.0867
Columns 9 through 10
0.6738 0.9204
>>
PS: I took built-in function mean as need only solution for part III