how does sum work?
1 回表示 (過去 30 日間)
古いコメントを表示
Pavel Kuzmitsky
2020 年 11 月 22 日
編集済み: Walter Roberson
2020 年 11 月 23 日
I don't understand what I'm doing wrong, it should be -1, but it turns out -0.5
but if you calculate separately for s=0 and s=1 and add it up, it turns out that -1 is true
clear
clc
n=2;
m=0;
k=(n-m)/2;
q=(n+m)/2;
r2=0;
s=0:k;
R=sum((r2.^(n-(2.*(s)))).*...
(((-1).^(s)).*(factorial(n-(s))))/...
((factorial(s)).*(factorial(q-(s))).*(factorial(k-(s)))))
also, if you can explain how to improve the formula so that it can be used when
r2=linspace(0,1,500);
if you can, write comments on actions in the response so that it is clear how your code works
0 件のコメント
採用された回答
Walter Roberson
2020 年 11 月 23 日
you have one / operator that should be ./
3 件のコメント
Walter Roberson
2020 年 11 月 23 日
編集済み: Walter Roberson
2020 年 11 月 23 日
n = 6;
m=0;
k=(n-m)/2;
q=(n+m)/2;
r2 = linspace(0,1,25);
s = (0:k).';
R = sum((r2.^(n-(2.*(s)))) .* ...
(((-1).^(s)).*(factorial(n-(s)))) ./ ...
((factorial(s)).*(factorial(q-(s))).*(factorial(k-(s)))));
size(R)
plot(r2, R);
xlabel('r2'); ylabel('R');
その他の回答 (0 件)
参考
カテゴリ
Help Center および File Exchange で Loops and Conditional Statements についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!