can I construct an anonymous function that is a double summation?
조회 수: 1 (최근 30일)
이전 댓글 표시
I want to write a double sum as an anonymous function, i.e., sum_i=1^n ( sum_j=1^n (k_i - k_j |) ). Writing the inner sum is trivial, i.e, f = @(x,n,i)sum(|x(i)-x(1:n)),then it's easy enough to sum these, i..e, v(i) = f(x,n,i) ; then sum(v(i)), but I can't figure out how to write the outer loop as an anonymous funct.
Thanks for any help.
댓글 수: 0
채택된 답변
추가 답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Function Creation에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!