2D summation loop
조회 수: 2 (최근 30일)
이전 댓글 표시
How do I create this in MATLAB?
댓글 수: 2
James Tursa
2019년 8월 22일
What have you done so far? What specific problems are you having with your code? Do you know how to write a for-loop, or use the sum( ) function, or use the diff( ) function, or use the .* operator?
채택된 답변
James Tursa
2019년 8월 23일
편집: James Tursa
2019년 8월 23일
Take the denominator for instance. Literally written out, this would be
denominator = 0;
for k=1:K
denominator = denominator + B(k,j)^2;
end
Or, assuming the first dimension of B is K, then you could use the sum( ) function:
denominator = sum(B(:,j).^2);
You can construct similar code for the numerator.
Probably best if you code everything up using for-loops just to get something running that works. Then you can simplify things with the sum( ) and diff( ) functions. It is possible to do the entire operation to construct ds without loops.
댓글 수: 4
James Tursa
2019년 8월 23일
If you have trouble, don't hesitate to post your current code and the problems you are having and we can still help you.
추가 답변 (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!