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

 채택된 답변

Walter Roberson
Walter Roberson 2020년 11월 23일

0 개 추천

you have one / operator that should be ./

댓글 수: 3

Pavel Kuzmitsky
Pavel Kuzmitsky 2020년 11월 23일
I have summation should occur when changing s, r2 is an array, what operators are we talking about?
James Tursa
James Tursa 2020년 11월 23일
(((-1).^(s)).*(factorial(n-(s))))/... <-- that one
Walter Roberson
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)
ans = 1×2
1 25
plot(r2, R);
xlabel('r2'); ylabel('R');

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

도움말 센터File Exchange에서 Programming에 대해 자세히 알아보기

제품

릴리스

R2020a

질문:

2020년 11월 22일

편집:

2020년 11월 23일

Community Treasure Hunt

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

Start Hunting!

Translated by