gpt4 book ai didi

matlab - 写出一次取两个或三个乘积的总和

转载 作者:行者123 更新时间:2023-12-02 21:31:22 25 4
gpt4 key购买 nike

我有变量 a1 a2 a3 a4.... 等等我想找出 F1 F2 F3 ...Fk...Fn哪里

      F1 =     a1+a2+a3+a4+.....an
F2 = - (sum of products of a's taken two at a time )
F3 = (sum of products of a's taken three at a time)
Fk = (-1)^(k+1)* (sum of products of a's taken k at a time)
and so on till Fn

谁能帮我如何通过伪代码或matlab代码获得Fk。 matlab中有没有内置函数可以帮助我做到这一点?

最佳答案

使用matlab中的内置函数poly(r),该函数取多项式的根r 作为数组:

function Fk = get_comb(r,k)   
p=poly(r)
Fk=(-1)^(k)*p(k+1);
end

关于matlab - 写出一次取两个或三个乘积的总和,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22222633/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com