フィルターのクリア

How can I calculate a double sum?

1 回表示 (過去 30 日間)
Solarmew
Solarmew 2015 年 5 月 24 日
コメント済み: Walter Roberson 2015 年 5 月 24 日
something like this
function test
syms u(x,t,r)
u(x,t,r) = x + t + r ;
tl = 0:2:4;
rl = 1:2:5;
ur = sum(u(x,tl,rl))
end
it works if i put in "r" instead of "rl" in the sum, but I want to sum over both "t" and "r"
  2 件のコメント
Solarmew
Solarmew 2015 年 5 月 24 日
編集済み: Solarmew 2015 年 5 月 24 日
got something, but is there a more elegant way then this?
function test2
syms u(x,t,r) u(x,r)
u(x,t,r) = x + t + r ;
tl = 0:1;
rl = 1:2;
ur(x,r) = sum(u(x,tl,r));
sum(ur(x,rl))
end
Walter Roberson
Walter Roberson 2015 年 5 月 24 日
Are you wanting each t with the r corresponding in the same position, or are you wanting the combinations, first t combined in turn with each of the elements of r, second t combined with each element of r, and so on? Should the number of summations be according to length of t which would have to be the same as length of r, or should the number be length of t multiplied by length of r?

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

回答 (0 件)

カテゴリ

Help Center および File ExchangeUtilities for the Solver についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by