フィルターのクリア

how to get the sum of the difference of the output from a multiplication and a data set

1 回表示 (過去 30 日間)
segun
segun 2015 年 11 月 28 日
編集済み: dpb 2015 年 11 月 28 日
Please i need hint on how to manipulate the output from a for loop do summation of differences between it and a data set. An example is shown below. I tried it but it only computed for the first for loop neglecting the other data set.
for f = [1 4 8 10 14];
b=2;
c=1;
d=1;
n=4;
N= f*b*c*d;
M=[4.5 10.5 20.5 25.6 30.8];
Y = (M-N);
A = sum(Y);
end
disp(A)

採用された回答

dpb
dpb 2015 年 11 月 28 日
編集済み: dpb 2015 年 11 月 28 日
OK, with the revised objective, no loop needed...
b=2;
c=1;
d=1;
n=4;
M=[4.5 10.5 20.5 25.6 30.8];
f=[1 4 8 10 14];
N= f*b*c*d;
A = sum(M-N);
disp(A)
  2 件のコメント
segun
segun 2015 年 11 月 28 日
I tried your the code it gave me five answers instead of a single answer which should be the total sum of "M-N" as a single figure .Please what should i do ?
dpb
dpb 2015 年 11 月 28 日
Oh, different problem than what you wrote...see updated answer.

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeMATLAB についてさらに検索

製品

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by