How to implement an equation containing nested Summations
1 回表示 (過去 30 日間)
古いコメントを表示
I am trying to write a matlab code to evaluate an error function given as:

I tried the following line of matlab code but there seems to be some problem with it.
E=0;
for i = 1:n-1
for j = i+1:n
for k = 1:n-1
for l = k+1:n
E =E + ((t(i,j)*(D(k) - D(l)) - t(k,l)*(D(i)-D(j))))^2;
end
end
end
end
I am not sure whether I have used the for loops correctly. Please advice. Thanks.
2 件のコメント
David Goodmanson
2019 年 11 月 27 日
Hi Sarath, it looks all right. There is an unneeded set of outermost parentheses which should not matter.
回答 (0 件)
参考
カテゴリ
Help Center および File Exchange で Matrix Indexing についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!