" is scalar and hence taking it as "r", but that shouldn't matter for this question. Also please initialize r, k before attemting to run the code. Here is the sample code:sum with odd n+k
조회 수: 2 (최근 30일)
이전 댓글 표시
I have a question about how to write a code for this kind of summation. k is predetrmined and my problem is about how to set (n+k odd):
Thank you in advance for your help...
댓글 수: 0
채택된 답변
Harshit Jain
2019년 2월 8일
I am assuming that "
" is scalar and hence taking it as "r", but that shouldn't matter for this question. Also please initialize r, k before attemting to run the code. Here is the sample code:
" is scalar and hence taking it as "r", but that shouldn't matter for this question. Also please initialize r, k before attemting to run the code. Here is the sample code:sum = 0;
for n = 0:k-1
if mod(k+n, 2) == 1
sum = sum + (2*n+1)*r;
end
end
Note: This is not an optimized code and you may write a more optimized implementation.
댓글 수: 0
추가 답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Get Started with Optimization Toolbox에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!