Hi This is my matlab problem Can you guys solve it Thanks Th
Solution
1. A = [7 5 3 23; 2 6 4 45; 8 9 3 12; 9 2 10 19]
A =
7 5 3 23
2 6 4 45
8 9 3 12
9 2 10 19
[M,I] = max(A)
M =
9 9 10 45
I =
4 3 4 2
r = I(1,2)
r = 3
fileID = fopen(\'myfile.txt\',\'w\');
fprintf(fileID,\'The ID of the student is \',A(r, 4))
A(r,4)
ans = 12
M,I] = max(A) will get the largest numbers column wise where M represents the values and I represents the indices. We know that the second quiz is in the 2nd column and I will have only 1 row.
hence we can directly get the value of the index by using I(1,2). this value represents the index for the row where the student has the highest mark in quiz 2. The corresponding row in column 4 will give the student ID.
2. A = [7 5 3 23; 2 6 4 45; 8 9 3 12; 9 2 10 19]
A =
7 5 3 23
2 6 4 45
8 9 3 12
9 2 10 19
Removing the last column which contains the student ID
A(:,4) = []
A =
7 5 3
2 6 4
8 9 3
9 2 10
calculating the average row wise
B = mean(A,2)
B =
5.0000
4.0000
6.6667
7.0000

