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

[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

 Réponse acceptée

keweraj
keweraj le 19 Nov 2022

0 votes

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

Plus de réponses (0)

Catégories

En savoir plus sur 循环及条件语句 dans Centre d'aide et File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!