column addding

11 ビュー (過去 30 日間)
mahaveer hanuman
mahaveer hanuman 2011 年 6 月 8 日
i mean i have: y= 1 2 5 3 5 7 2 6 4
x= 1 -2 7 x= 3 5 4 x= 2 -6 2 now i need output as: z=(1-1)^2+(2+2)^2+(5-7)^2 =20 and so on
and so on for z(1),z(2). please help!!

採用された回答

Andrei Bobrov
Andrei Bobrov 2011 年 6 月 8 日
y = [1 2 5 3 5 7 2 6 4];
x = [1 -2 7 3 5 4 2 -6 2];
z = sum(reshape((x-y).^2,3,[]));
  1 件のコメント
mahaveer hanuman
mahaveer hanuman 2011 年 6 月 8 日
thanks

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

その他の回答 (0 件)

カテゴリ

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

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by