??? Index exceeds matrix dimensions.

1 次查看(过去 30 天)
MinHyung
MinHyung 2013-8-20
I tried to use function 'quad' but failed...
>> quad (@(phi) (224 - 32*sin(7) + 32*cos((7.*cos(phi))./2).^2.*sin(7) + 32*cos((7.*sin(phi))./2).^2.*sin(7) - 224*cos((7*cos(phi))./2).^2 - 224*cos((7*sin(phi))./2).^2 - 32*cos((7*cos(phi))./2).^2.*cos((7*sin(phi))./2).^2.*sin(7) + 224*cos((7*cos(phi))./2).^2.*cos((7*sin(phi))./2).^2)/(823543.*cos(phi).^2 - 823543*cos(phi).^4), 0.1,pi/2-0.1)
??? Index exceeds matrix dimensions.
Error in ==> quad at 85
if ~isfinite(y(7))
--------------------------------------------------------------------
'quad' with separate part works well
this part :
(224 - 32*sin(7) + 32*cos((7.*cos(phi))./2).^2.*sin(7) + 32*cos((7.*sin(phi))./2).^2.*sin(7) - 224*cos((7*cos(phi))./2).^2 - 224*cos((7*sin(phi))./2).^2 - 32*cos((7*cos(phi))./2).^2.*cos((7*sin(phi))./2).^2.*sin(7) + 224*cos((7*cos(phi))./2).^2.*cos((7*sin(phi))./2).^2)
and this part :
(823543.*cos(phi).^2 - 823543*cos(phi).^4
Is there anyone who knows this reason?
Thank you very much in advance.

回答(1 个)

the cyclist
the cyclist 2013-8-20
编辑:the cyclist 2013-8-20
Do you get what you expect if you use "./" instead of just "/" for the division of your two terms?
This code works for me:
f1 = @(phi) (823543.*cos(phi).^2 - 823543*cos(phi).^4);
f2 = @(phi) (224 - 32*sin(7) + 32*cos((7.*cos(phi))./2).^2.*sin(7) + 32*cos((7.*sin(phi))./2).^2.*sin(7) - 224*cos((7*cos(phi))./2).^2 - 224*cos((7*sin(phi))./2).^2 - 32*cos((7*cos(phi))./2).^2.*cos((7*sin(phi))./2).^2.*sin(7) + 224*cos((7*cos(phi))./2).^2.*cos((7*sin(phi))./2).^2);
f3 = @(phi) f2(phi)./f1(phi);
quad(f3,0.1,pi/2-0.1)
  2 个评论
MinHyung
MinHyung 2013-8-20
Thank you very much! This problem consume my time a lot ㅠㅠ
the cyclist
the cyclist 2013-8-20
I would appreciate it if you "accept" the answer, which may also help someone in the future who seeks a similar solution.

请先登录,再进行评论。

类别

Help CenterFile Exchange 中查找有关 MATLAB 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by