带循环的复杂公式的表达问题。

21 次查看(过去 30 天)
padel
padel 2022-11-19
回答: keweraj 2022-11-19
[code]function result
for j=1:10
f=@(x)(((1-x.^j)^(1-.j).*x.^(j.*(j-1)))+1).^(1./j);
g=mgsint(f,0,1,1000000,5)
end[/code]
错误代码是这样的
??? Error using ==> mpower
Inputs must be a scalar and a square matrix.
Error in ==> result>@(x)(((1-x.^j)^(1-j).*x.^(j.*(j-1)))+1).^(1/j) at 3
f=@(x)(((1-x.^j)^(1-j).*x.^(j.*(j-1)))+1).^(1/j);
Error in ==> mgsint>gsint at 30
g=(b-a)/2*sum(A.*feval(f,(b-a)/2*t+(a+b)/2));
Error in ==> mgsint at 26
g=g+gsint(f,x(i),x(i+1),A,t);
Error in ==> result at 4
g=mgsint(f,0,1,1000000,5)
我想的是mgsint里的错误应该就是公式表达出错才造成的 所以可以暂时不管mgsint函数
原始的表达式是这样的
p就是那个循环参数i

采纳的回答

keweraj
keweraj 2022-11-19
不知道你要表达什么。
如果你是想说为什么会报错的话,是因为(1-x.^j)^(1-.j)中少点乘,即应该写作(1-x.^j).^(1-.j)。
P.S. 你主函数function result是干嘛的啊。。。

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 电子表格 的更多信息

标签

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!