double summation without a loop
이전 댓글 표시
I have an anonymous function f that has two indices, i and t. i runs from 1 to n; t runs from 1 to m != n. For example:
f = @(delta,i,t) exp( - delta(i).*t );
delta = rand(1:n);
Obviously, I can sum f with respect to either t or i,
sum(f(delta,1:n,t))
sum(f(delta,i,1:m))
But I'd like to compute, in one step, sum_i=1^n (sum_t=1^m f(delta,i,t)) , without writing a loop. Is this possible? thanks very much for any advice!
채택된 답변
추가 답변 (0개)
카테고리
도움말 센터 및 File Exchange에서 Matrix Operations and Transformations에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!