Hi. How I can write this formula with Matlab code?
显示 更早的评论

2 个评论
Rik
2023-1-21
That depends on what psi is, but with a nested loop this is trivial. What did you try?
Aynur Resulzade
2023-1-22
编辑:Aynur Resulzade
2023-1-22
回答(1 个)
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 个评论
Aynur Resulzade
2023-1-23
编辑:Rik
2023-1-23
Aynur Resulzade
2023-1-23
Bruno Luong
2023-1-23
编辑:Bruno Luong
2023-1-23
@Aynur Resulzade You must kidding me. I'll delete my answer
Aynur Resulzade
2023-1-23
编辑:Aynur Resulzade
2023-1-23
类别
在 帮助中心 和 File Exchange 中查找有关 Programming 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
