task -6 -5 -4 -1 -2 -9 fprintf tTask disp disp sum for length sum sum

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
% task 8
% M = [2 3 1 -6 8 7 9;
% 0 -5 -4 1 2 5 8;
% 3 4 -1 0 2 1 8;
% -2 -9 0 4 5 2 0];
%
% fprintf('\n\t\tTask 8\n');
% disp('M = ');
% disp(M);
%
% sum = 0;
% for i=2:length(M)
% sum = sum + M(2, i);
% end
% disp('Sum = ');
% disp(sum);
% task 9
M = [2 3 1 -6 8 7 9;
0 -5 -4 1 2 5 8;
3 4 -1 0 2 1 8;
-2 -9 0 4 5 2 0];
fprintf('\n\t\tTask 9\n');
disp('M = ');
disp(M);
sum = 0;
for i = 1:size(M, 1)
sum = sum + M(i, 3);
end
disp('Sum = ');
disp(sum);