Integration help (quad)

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 Kommentar

John D'Errico
John D'Errico am 8 Apr. 2011
So what error did you get???? You only wrote part of the error here, the part that gives insufficient information!

Melden Sie sich an, um zu kommentieren.

 Akzeptierte Antwort

Matt Fig
Matt Fig am 8 Apr. 2011

0 Stimmen

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)

Weitere Antworten (2)

Friedrich
Friedrich am 8 Apr. 2011

1 Stimme

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 am 21 Apr. 2011

0 Stimmen

Thanks Friedrich and Matt.
Jeff

Community Treasure Hunt

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

Start Hunting!

Translated by