TASK 1: So I have a simple vector and I needed to compare if first column is greater than the second column.
TASK 2: This time I need to calculate the sum of the first 3 columns and also print the last column. Repeating each row. Now say the vector has become a 4 x 4.
M = [1042 713 4 42; 30 48 0 12; 4 160 12 1; 1 111 2 0]
sum = M(:, 1) + M(:, 2) + M(:, 3);
fprintf('Sum of values: %.0f, extra value: %.0f\n', [sum(:),extra(:)].');
TASK 3: Now I need to extend Task 2 by repeating Task 1 of comparing the first column to the second column of each row.
The format will be like this: Sum of values: "val1", extra value: "val2" increasing (*or decreasing)
What I've came up with is this and so far it hasn't been working since it prints decreasing for every row even tho first one is increasing.
for sum3 = M(:, 1) + M(:, 2) + M(:, 3);
fprintf('Sum of values: %.0f, extra value: %.0f increasing\n'...
fprintf('Sum of values: %.0f, extra value: %.0f decreasing\n'...
How to simplify or code this properly? Thank you :)