shegmite
Member level 1
Please i need hint on how to store the output from a for loop multiplication horizontally and then subtract it from a data set arranged horizontally to get the sum .An example is shown below though not the whole manipulation code. I want the computer to do the subtraction as :
20.5-5.2 , 30.6-10.3, 40.6-20.5 and so on and then sum the differences.An illustration of what i want is shown below.
20.5-5.2 , 30.6-10.3, 40.6-20.5 and so on and then sum the differences.An illustration of what i want is shown below.
Code:
% output from a for loop needed to be stored horizontally as
Au = 5.2 10.3 20.5 30.4 45.6 50.6 55.7 60.8 75.8 80.9
% data set to be subtracted typed horizontally as
Ab = [20.5 30.6 40.6 50.7 60.6 70.8 80.8 90.9 97.9 90.2];
Y = (Ab-Au);
Z = sum(Y);
disp(Z)
Last edited by a moderator: