Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

Thread Subject:
help me ! double integral

Subject: help me ! double integral

From: ttattl ttattl

Date: 8 May, 2011 02:57:05

Message: 1 of 9

I have problem how to discrete ( approximate ):

I = int(0,tn) int(0,s) f(u)duds

With tn is array o [0->1] . I divided into 1000 point

Subject: help me ! double integral

From: Roger Stafford

Date: 8 May, 2011 03:44:06

Message: 2 of 9

"ttattl ttattl" <trantuananh2006@gmail.com> wrote in message <iq50q1$j66$1@newscl01ah.mathworks.com>...
> I have problem how to discrete ( approximate ):
>
> I = int(0,tn) int(0,s) f(u)duds
>
> With tn is array o [0->1] . I divided into 1000 point
- - - - - - - - - -
  The way you have phrased your question sounds as though you want a vector answer with a thousand elements, one for each value of tn. If you have f(u) defined for a thousand values from 0 to 1, you could do cumtrapz on these f(u) values and then do cumtrapz on the result.

Roger Stafford

Subject: help me ! double integral

From: ttattl ttattl

Date: 8 May, 2011 11:00:20

Message: 3 of 9

"Roger Stafford" wrote in message <iq53i5$oul$1@newscl01ah.mathworks.com>...
> "ttattl ttattl" <trantuananh2006@gmail.com> wrote in message <iq50q1$j66$1@newscl01ah.mathworks.com>...
> > I have problem how to discrete ( approximate ):
> >
> > I = int(0,tn) int(0,s) f(u)duds
> >
> > With tn is array o [0->1] . I divided into 1000 point
> - - - - - - - - - -
> The way you have phrased your question sounds as though you want a vector answer with a thousand elements, one for each value of tn. If you have f(u) defined for a thousand values from 0 to 1, you could do cumtrapz on these f(u) values and then do cumtrapz on the result.
>
> Roger Stafford
------------------------------------------------------------------------------
thanks for your reply
 you right ! f(u) is de fined for a thousand values from 0 to 1 and we have it ! But you can tell me more about cumtrapz ! I not understand it ! more detail for this ! please

Thanks

Subject: help me ! double integral

From: ttattl ttattl

Date: 8 May, 2011 13:48:04

Message: 4 of 9

"ttattl ttattl" <trantuananh2006@gmail.com> wrote in message <iq5t44$i58$1@newscl01ah.mathworks.com>...
> "Roger Stafford" wrote in message <iq53i5$oul$1@newscl01ah.mathworks.com>...
> > "ttattl ttattl" <trantuananh2006@gmail.com> wrote in message <iq50q1$j66$1@newscl01ah.mathworks.com>...
> > > I have problem how to discrete ( approximate ):
> > >
> > > I = int(0,tn) int(0,s) f(u)duds
> > >
> > > With tn is array o [0->1] . I divided into 1000 point
> > - - - - - - - - - -
> > The way you have phrased your question sounds as though you want a vector answer with a thousand elements, one for each value of tn. If you have f(u) defined for a thousand values from 0 to 1, you could do cumtrapz on these f(u) values and then do cumtrapz on the result.
> >
> > Roger Stafford
> ------------------------------------------------------------------------------
> thanks for your reply
> you right ! f(u) is de fined for a thousand values from 0 to 1 and we have it ! But you can tell me more about cumtrapz ! I not understand it ! more detail for this ! please
>
> Thanks

--------------------------------

I will write more clearly what I mean
 We have t_n from 0->1 ! dt =1/1000
with every t_n We have alpha (t_n ).

Now we need double integral alpha (t_n)

I =int (o, t_n) int(0,s) alpha(u_n) du_n ds

We input
y=cumtrapz(alpha);
z=cumtrapz(y);
and z is result ??
I not clear this ( may be it wrong )

Please help me

Subject: help me ! double integral

From: Roger Stafford

Date: 8 May, 2011 19:27:04

Message: 5 of 9

"ttattl ttattl" <trantuananh2006@gmail.com> wrote in message <iq66uk$8qd$1@newscl01ah.mathworks.com>...
> .......
> We input
> y=cumtrapz(alpha);
> z=cumtrapz(y);
> and z is result ??
> I not clear this ( may be it wrong )
>
> Please help me
- - - - - - - - - -
  Well, that is the general idea, but you need to include the variable you are integrating with respect to, namely u:

 z = cumtrapz(u,cumtrapz(u,alpha));

where u is (0:0.001:1).' and alpha is a column vector of the corresponding values of alpha. (The vectors u and alpha may also be row vectors with cumtrapz.)

  You should be aware that 'cumtrapz' uses a trapezoidal approximation for the cumulative integral. If that is not accurate enough for your purposes, you could use the cubic cumulative integral that I wrote for the Matlab Central File Exchange. It is to be found at

 http://www.mathworks.com/matlabcentral/fileexchange/19152

It is named 'cumint3' and is called in the same way as 'cumtrapz' but uses third order approximation instead of cumtrapz's first order and is therefore more accurate, provided the alpha values are sufficiently free of noise errors. As I recall cumint3 accepts only column vectors.

  As a demonstration I tried 'cumint3' out for alpha = (u+1)^4, which by calculus gives your problem an exact answer of 1.9 at t = 1, and got the following approximation:

 u = (0:.001:1).';
 z = cumint3(u,cumint3(u,(u+1).^4));
 format long
 z(end)
    = 1.89999999999927

so it is quite accurate for such smooth functions and small intervals.

Roger Stafford

Subject: help me ! double integral

From: ttattl ttattl

Date: 9 May, 2011 01:02:04

Message: 6 of 9

"Roger Stafford" wrote in message <iq6qq8$jus$1@newscl01ah.mathworks.com>...
> "ttattl ttattl" <trantuananh2006@gmail.com> wrote in message <iq66uk$8qd$1@newscl01ah.mathworks.com>...
> > .......
> > We input
> > y=cumtrapz(alpha);
> > z=cumtrapz(y);
> > and z is result ??
> > I not clear this ( may be it wrong )
> >
> > Please help me
> - - - - - - - - - -
> Well, that is the general idea, but you need to include the variable you are integrating with respect to, namely u:
>
> z = cumtrapz(u,cumtrapz(u,alpha));
>
> where u is (0:0.001:1).' and alpha is a column vector of the corresponding values of alpha. (The vectors u and alpha may also be row vectors with cumtrapz.)
>
> You should be aware that 'cumtrapz' uses a trapezoidal approximation for the cumulative integral. If that is not accurate enough for your purposes, you could use the cubic cumulative integral that I wrote for the Matlab Central File Exchange. It is to be found at
>
> http://www.mathworks.com/matlabcentral/fileexchange/19152
>
> It is named 'cumint3' and is called in the same way as 'cumtrapz' but uses third order approximation instead of cumtrapz's first order and is therefore more accurate, provided the alpha values are sufficiently free of noise errors. As I recall cumint3 accepts only column vectors.
>
> As a demonstration I tried 'cumint3' out for alpha = (u+1)^4, which by calculus gives your problem an exact answer of 1.9 at t = 1, and got the following approximation:
>
> u = (0:.001:1).';
> z = cumint3(u,cumint3(u,(u+1).^4));
> format long
> z(end)
> = 1.89999999999927
>
> so it is quite accurate for such smooth functions and small intervals.
>
> Roger Stafford

-------------------
thank you very much

I have tried with z = cumtrapz(u,cumtrapz(u,alpha)); it ok !
But when I try with z = cumint3(u,cumint3(u,alpha)); it wrong !

I see in file cumint3 of you has somthing wrong ?

you put [n,m]= size(x)
that mean when I put x=[1 2 3 4 5] , n=1 and m=5 ! it wrong because you need n>=4 !
That mean we can't input x like a vector ??

Subject: help me ! double integral

From: ttattl ttattl

Date: 9 May, 2011 01:08:04

Message: 7 of 9

"ttattl ttattl" <trantuananh2006@gmail.com> wrote in message <iq7eec$1go$1@newscl01ah.mathworks.com>...
> "Roger Stafford" wrote in message <iq6qq8$jus$1@newscl01ah.mathworks.com>...
> > "ttattl ttattl" <trantuananh2006@gmail.com> wrote in message <iq66uk$8qd$1@newscl01ah.mathworks.com>...
> > > .......
> > > We input
> > > y=cumtrapz(alpha);
> > > z=cumtrapz(y);
> > > and z is result ??
> > > I not clear this ( may be it wrong )
> > >
> > > Please help me
> > - - - - - - - - - -
> > Well, that is the general idea, but you need to include the variable you are integrating with respect to, namely u:
> >
> > z = cumtrapz(u,cumtrapz(u,alpha));
> >
> > where u is (0:0.001:1).' and alpha is a column vector of the corresponding values of alpha. (The vectors u and alpha may also be row vectors with cumtrapz.)
> >
> > You should be aware that 'cumtrapz' uses a trapezoidal approximation for the cumulative integral. If that is not accurate enough for your purposes, you could use the cubic cumulative integral that I wrote for the Matlab Central File Exchange. It is to be found at
> >
> > http://www.mathworks.com/matlabcentral/fileexchange/19152
> >
> > It is named 'cumint3' and is called in the same way as 'cumtrapz' but uses third order approximation instead of cumtrapz's first order and is therefore more accurate, provided the alpha values are sufficiently free of noise errors. As I recall cumint3 accepts only column vectors.
> >
> > As a demonstration I tried 'cumint3' out for alpha = (u+1)^4, which by calculus gives your problem an exact answer of 1.9 at t = 1, and got the following approximation:
> >
> > u = (0:.001:1).';
> > z = cumint3(u,cumint3(u,(u+1).^4));
> > format long
> > z(end)
> > = 1.89999999999927
> >
> > so it is quite accurate for such smooth functions and small intervals.
> >
> > Roger Stafford
>
> -------------------
> thank you very much
>
> I have tried with z = cumtrapz(u,cumtrapz(u,alpha)); it ok !
> But when I try with z = cumint3(u,cumint3(u,alpha)); it wrong !
>
> I see in file cumint3 of you has somthing wrong ?
>
> you put [n,m]= size(x)
> that mean when I put x=[1 2 3 4 5] , n=1 and m=5 ! it wrong because you need n>=4 !
> That mean we can't input x like a vector ??


-----------------------------------
if i change position of m,n that mean [m,n] = size (x);
the errors when put xe = [x(4);x;x(n-3)]; ye = [y(4);y;y(n-3)]; is ??? Error using ==> vertcat
CAT arguments dimensions are not consistent.

Subject: help me ! double integral

From: Roger Stafford

Date: 9 May, 2011 05:26:04

Message: 8 of 9

"ttattl ttattl" <trantuananh2006@gmail.com> wrote in message <iq7epk$24f$1@newscl01ah.mathworks.com>...
> "ttattl ttattl" <trantuananh2006@gmail.com> wrote in message <iq7eec$1go$1@newscl01ah.mathworks.com>...
> > thank you very much
> >
> > I have tried with z = cumtrapz(u,cumtrapz(u,alpha)); it ok !
> > But when I try with z = cumint3(u,cumint3(u,alpha)); it wrong !
> >
> > I see in file cumint3 of you has somthing wrong ?
> >
> > you put [n,m]= size(x)
> > that mean when I put x=[1 2 3 4 5] , n=1 and m=5 ! it wrong because you need n>=4 !
> > That mean we can't input x like a vector ??
> -----------------------------------
> if i change position of m,n that mean [m,n] = size (x);
> the errors when put xe = [x(4);x;x(n-3)]; ye = [y(4);y;y(n-3)]; is ??? Error using ==> vertcat
> CAT arguments dimensions are not consistent.
- - - - - - - - - -
  Remember, I warned you that 'cumint3' accepts only column vectors. That means they can have many rows but only one column. The example I used with variable u was written:

  u = (0:.001:1).';

which makes both u and (u+1).^4 column vectors, as cumint2 requires.

Roger Stafford

Subject: help me ! double integral

From: ttattl ttattl

Date: 11 May, 2011 02:42:04

Message: 9 of 9

"Roger Stafford" wrote in message <iq7ttc$41g$1@newscl01ah.mathworks.com>...
> "ttattl ttattl" <trantuananh2006@gmail.com> wrote in message <iq7epk$24f$1@newscl01ah.mathworks.com>...
> > "ttattl ttattl" <trantuananh2006@gmail.com> wrote in message <iq7eec$1go$1@newscl01ah.mathworks.com>...
> > > thank you very much
> > >
> > > I have tried with z = cumtrapz(u,cumtrapz(u,alpha)); it ok !
> > > But when I try with z = cumint3(u,cumint3(u,alpha)); it wrong !
> > >
> > > I see in file cumint3 of you has somthing wrong ?
> > >
> > > you put [n,m]= size(x)
> > > that mean when I put x=[1 2 3 4 5] , n=1 and m=5 ! it wrong because you need n>=4 !
> > > That mean we can't input x like a vector ??
> > -----------------------------------
> > if i change position of m,n that mean [m,n] = size (x);
> > the errors when put xe = [x(4);x;x(n-3)]; ye = [y(4);y;y(n-3)]; is ??? Error using ==> vertcat
> > CAT arguments dimensions are not consistent.
> - - - - - - - - - -
> Remember, I warned you that 'cumint3' accepts only column vectors. That means they can have many rows but only one column. The example I used with variable u was written:
>
> u = (0:.001:1).';
>
> which makes both u and (u+1).^4 column vectors, as cumint2 requires.
>
> Roger Stafford

---------------------------------------
thank you very much ! I see this work so good
But now by mathematic I see away to calculus this !
follow link ! http://www.mediafire.com/?tsik8k54y6aofy8
Is it exactly ? thanks

Tags for this Thread

No tags are associated with this thread.

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

Contact us