help-octave
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Integration problem


From: Ivan Sutoris
Subject: Re: Integration problem
Date: Thu, 8 Jan 2009 23:31:33 +0100

On Thu, Jan 8, 2009 at 10:14 PM, Marcin Sleczka <address@hidden> wrote:
>
> Hi,
> Why it does not work?
>>u=[-10:0.1:10];
>>function y=int(u,x)
>>y=sin(u.*x);
>>endfunction;
>
>>y=quad("int",0,2.*pi);
>
> I would like to plot such a function:
> f(u)=\int_{0}^{2\pi}sin(ux)dx
>
> Any idea how to do it?
>
> Thanks for help.
> MS

Hi

if you use quad, the function you integrate must accept one scalar
argument, while your function accepts two arguments (so one of them is
undefined when it is called form quad). To compute your function, I
would try something like this:

u = -10:0.01:10;

function r = f(u)
% f(u)=\int_{0}^{2\pi}sin(ux)dx
    for i=1:length(u)
        intfun = @(x) sin(u(i)*x);
        r(i) = quad(intfun,0,2*pi);
    end
end

plot (u,f(u))

Regards
Ivan Sutoris


reply via email to

[Prev in Thread] Current Thread [Next in Thread]