Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

integer a function in matlab

8 views
Skip to first unread message

ginafort

unread,
Sep 2, 2010, 1:39:55 PM9/2/10
to
Please what commande i must to use in matlab for integrate my function: dg/dt = f(t)
thank you to orient me

Greg Heath

unread,
Sep 2, 2010, 7:31:42 PM9/2/10
to
On Sep 2, 1:39 pm, ginafort <najl...@yahoo.fr> wrote:
> Please what commande i must to use in matlab for integrate my function: dg/dt = f(t)
> thank you to orient me

>> lookfor integral
...
QUAD Numerically evaluate integral, adaptive Simpson quadrature.
QUAD8 Numerically evaluate integral, higher order method.
QUADL Numerically evaluate integral, adaptive Lobatto quadrature.
...

Hope this helps.

Greg

ginafort

unread,
Sep 3, 2010, 8:22:59 AM9/3/10
to
thanks greg,
but i want to have a primitive function, i want to draw a primitive of my function.
with the commande "quad" i must to have the bounds of the integral

Wayne King

unread,
Sep 3, 2010, 8:46:08 AM9/3/10
to
ginafort <naj...@yahoo.fr> wrote in message <1315703166.159523.1283...@gallium.mathforum.org>...

> thanks greg,
> but i want to have a primitive function, i want to draw a primitive of my function.
> with the commande "quad" i must to have the bounds of the integral

Hi, do you want to integrate symbolically? If you have the Symbolic Toolbox, you can do the following:

syms x y
y = x^2;
z=int(y)


The above gives the antiderivative with the constant of integration equal to zero.

% Now plot the derivative and antiderivative
ezplot(y,[-5 5]); hold on;
h = ezplot(z,[-5 5]);
set(h,'linewidth',2,'color',[1 0 0 ]);
title('x^2 and x^3/3');

Hope that helps,
Wayne

ginafort

unread,
Sep 3, 2010, 9:11:41 AM9/3/10
to
I have dg/dt=.... and i want to plot g=f(t).
how to de it in matlab?
please your help

Pete

unread,
Sep 3, 2010, 5:53:23 PM9/3/10
to

Consider the integral as an ODE for g (as a special case where the RHS
does not depend on g).

Then use a standard ODE solver with odefun=f(t) and initial condition
g(t0)=0.

For example:

f=@(t,y) t.^2.*exp(-t);
[t,g] = ode45(f,[0,10],0);
plot(t,g);

Good luck,
Pete

0 new messages