フィルターのクリア

how to make output a for loop subtract sequentially a data set below it to give sum of differences

1 回表示 (過去 30 日間)
I need syntax in matlab to make the output of the for loop(Y) subtract sequentially the data (X) below and give the sum of the differences as answer. for f = [1 4 8 10 12 16 18 20]; b=2; c=1; d=1; n=4; Y=b*c*d*n*f X = [10 13 15 12 17 23 26 19]; Z = abs(Y-X); A=0; A= A+sum(Z);

採用された回答

George Papazafeiropoulos
George Papazafeiropoulos 2014 年 5 月 23 日
Do you want this:
b=2;
c=1;
d=1;
n=4;
Y=b*c*d*n;
X = [10 13 15 12 17 23 26 19];
f = [1 4 8 10 12 16 18 20];
A=length(f)*sum(abs(Y-X));
A
  1 件のコメント
segun
segun 2014 年 5 月 23 日
Sorry I forgot to tell you that the for loop f is part of the multiplication i.e. Y = f*b*c*d*n .Please kindly correct it and re do the syntax. Thanks

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeLoops and Conditional Statements についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by