Double summation with nested sum

10 ビュー (過去 30 日間)
Ali Moghanni
Ali Moghanni 2017 年 12 月 23 日
コメント済み: Ali Moghanni 2017 年 12 月 27 日
I need to write this in Matlab. I need some help.Thanks in advance.

採用された回答

Image Analyst
Image Analyst 2017 年 12 月 23 日
編集済み: Image Analyst 2017 年 12 月 24 日
Is this homework? If so click here
Break it into 3 parts. A function to compute the first sum, a function to compute the second sum, and a script to call those two functions and subtract them and square them and do it 29 times, then add the final terms. Shouldn't be too hard. Show your work if you get stuck
s3 = 0;
for i = 2 : 30
s1 = sum1(x); % Call function sum1().
s2 = sum2(x); % Call function sum2().
s3 = s3 + (s1 - s2^2 - 1)^2;
end
s4 = s3 + x(1)^2 + (.......... etc.
  1 件のコメント
Ali Moghanni
Ali Moghanni 2017 年 12 月 27 日
Thank you very much, I wrote the code.

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

その他の回答 (1 件)

Walter Roberson
Walter Roberson 2017 年 12 月 23 日
V = @(M) M(:);
part1 = sum(bsxfun( @times, V(x(2:30)), 1:9 ) .* bsxfun(@power, (1:29).'/29, 0:8 ), 2);
part2 = sum(bsxfun( @times, V(x(2:30)), bsxfun(@power, (1:29).'/29, 1:9 )), 2).^2;
part3 = sum((part1 - part2 - 1).^2);
result = part3 + x(1).^2 + (x(2) - x(1).^2 - 1).^2;

カテゴリ

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

Community Treasure Hunt

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

Start Hunting!

Translated by