Hi. How I can write this formula with Matlab code?
2 ビュー (過去 30 日間)
古いコメントを表示
2 件のコメント
Rik
2023 年 1 月 21 日
That depends on what psi is, but with a nested loop this is trivial. What did you try?
回答 (1 件)
Bruno Luong
2023 年 1 月 21 日
n=10;
psi=rand(1,n-2);
chi = 0;
for k=1:n-2
i = nchoosek(1:n-2,k);
j = 1:k;
l = k+1-j;
il = i(:,l);
chi = chi+sum(prod(psi(il),2));
end
chi
% Or remove some of the unecessary indexing with j and l
chi = 0;
for k=1:n-2
chi = chi+sum(prod(psi(nchoosek(1:n-2,k)),2));
end
chi
4 件のコメント
Bruno Luong
2023 年 1 月 23 日
編集済み: Bruno Luong
2023 年 1 月 23 日
@Aynur Resulzade You must kidding me. I'll delete my answer
参考
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!