help-octave
[Top][All Lists]
Advanced

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

RE: diff(x) question


From: Van den Eynde Gert
Subject: RE: diff(x) question
Date: Tue, 19 Jan 1999 08:37:32 +0100

> 
> t=[1:.1:10]
> x=sin(t)
> and I want to plot the derivative of sin(t) (but I want to compute it)
> 
> I tried
> y=diff(x)
> 
> and then plot(t,x,t,y) yields me an error message that states the
> the vector sizes must be the same.. so I did
> plot(t,x,[1.1:.1:10],y)
> 
> and it worked, but the y is really small and never goes beyond .1 in
> value.  Do you think you could point me in the right direction?
> I guess I'm differentiating wrong, how should this really be done?
> 

Diff computes forward differences. Not the derivative. If you want to 
approximate the derivative by using forward differences you have to 
divide by the step h with which you make your function discrete.
In this case h = .1


df          f(t+h) - f(t)
-- (t) =~  --------------- + O(h)
dt                h



Sincere greetings,
Gert Van den Eynde

                                ''''' 
                               (-o-o-)
 _________________________.oooO--(_)--Oooo._________________________
| Gert Van den Eynde                      mailto:address@hidden |
| SCK-CEN                      http://www.sckcen.be/people/gvdeynde |
| FLINS                                                             |
| Boeretang 200                                                     |
| B-2400 Mol               .oooO                                    |
| Belgium                  (   )   Oooo.                            |
|___________________________\ (____(   )____________________________|
                             \_)    ) /
                                   (_/



reply via email to

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