Integration help (quad)

2 次查看(过去 30 天)
Jeffrey
Jeffrey 2011-4-8
New to Matlab and stuck trying to integrate trigXtrig function.
Here's what I've been doing:
function y=rfun(theta)
y=(cos(theta).*sin(theta).);
end
EDU>> q=quad('rfun',0,0.644)
But I get this error:
Error in ==> quad at 77
y = f(x, varargin{:});
  1 个评论
John D'Errico
John D'Errico 2011-4-8
So what error did you get???? You only wrote part of the error here, the part that gives insufficient information!

请先登录,再进行评论。

采纳的回答

Matt Fig
Matt Fig 2011-4-8
Why not use an anonymous function instead?
>> y = @(th) cos(th).*sin(th); % The function to integrate...
>> q = quad(y,0,0.644) % Also, quadl(y,0,0.644)

更多回答(2 个)

Friedrich
Friedrich 2011-4-8
Hi Jeffrey,
I think you get this error because of the extra dot after sin(theta). You function rfun should look like this:
function y=rfun(theta)
y=(cos(theta).*sin(theta));
end
I hope I could help, Friedrich

Jeffrey
Jeffrey 2011-4-21
Thanks Friedrich and Matt.
Jeff

类别

Help CenterFile Exchange 中查找有关 Pole and Zero Locations 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by