Thread Subject: Create a vector of derivatives, given a vector of values

Subject: Create a vector of derivatives, given a vector of values

From: Johan

Date: 16 Oct, 2008 03:47:01

Message: 1 of 5

Am looking for recommendations about how to create a vector of derivatives given a vector of values.

In this case, I have an array with temperatures at different times (evenly spaced). I want to create an array of temperature derivatives. (I anticipate losing a few points at the ends.)

Could write a loop, I suppose, dT/dt_i = (T_i+1 - T_i)/dt
But there are 20,000 points.

Is there some vectorized scheme or existing function that I should look into?

Thanks.

Subject: Create a vector of derivatives, given a vector of values

From: Bruno Luong

Date: 16 Oct, 2008 05:40:04

Message: 2 of 5

"Johan " <robert.mchugh@ips.invensys.com> wrote in message <gd6dfl$be8$1@fred.mathworks.com>...

> Is there some vectorized scheme or existing function that I should look into?

help diff

Bruno

Subject: Create a vector of derivatives, given a vector of values

From: Johan

Date: 16 Oct, 2008 15:14:02

Message: 3 of 5

Thanks. "help diff" works much better than "help derivative." :)

Turns out the data is a little noisy, so estimating the derivative by comparing just two adjacent points produces oscillating derivatives.

Are there existing tools to smooth this out?

Regards.

"Bruno Luong" <b.luong@fogale.findmycountry> wrote in message <gd6k3j$515$1@fred.mathworks.com>...
> "Johan " <robert.mchugh@ips.invensys.com> wrote in message <gd6dfl$be8$1@fred.mathworks.com>...
>
> > Is there some vectorized scheme or existing function that I should look into?
>
> help diff
>
> Bruno

Subject: Create a vector of derivatives, given a vector of values

From: Bruno Luong

Date: 16 Oct, 2008 18:01:03

Message: 4 of 5

"Johan " <robert.mchugh@ips.invensys.com> wrote in message <gd7lnq$h82$1@fred.mathworks.com>...

>
> Are there existing tools to smooth this out?
>
> Regards.
>

You might fit (avoid interpolate) the data with a model, then take a derivative of a fitted model. If you don't know the model, then using a universal cubic spline for model could better way than diff.

Bruno

Subject: Create a vector of derivatives, given a vector of values

From: John D'Errico

Date: 16 Oct, 2008 20:24:03

Message: 5 of 5

"Johan " <robert.mchugh@ips.invensys.com> wrote in message <gd6dfl$be8$1@fred.mathworks.com>...
> Am looking for recommendations about how to create a vector of derivatives given a vector of values.
>
> In this case, I have an array with temperatures at different times (evenly spaced). I want to create an array of temperature derivatives. (I anticipate losing a few points at the ends.)
>
> Could write a loop, I suppose, dT/dt_i = (T_i+1 - T_i)/dt
> But there are 20,000 points.
>
> Is there some vectorized scheme or existing function that I should look into?
>
> Thanks.

Yes. Just look for a Savitsky-Golay tool. There
are many of them on the file exchange. Here
are a couple of them.

http://www.mathworks.com/matlabcentral/fileexchange/loadFile.do?objectId=16997&objectType=FILE

http://www.mathworks.com/matlabcentral/fileexchange/loadFile.do?objectId=4038&objectType=file

John

Tags for this Thread

Everyone's Tags:

Add a New Tag:

Separated by commas
Ex.: root locus, bode

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.

Tag Activity for This Thread
Tag Applied By Date/Time
derivative esti... Johan 15 Oct, 2008 23:50:06
vectors Johan 15 Oct, 2008 23:50:06
rssFeed for this Thread

Contact us at files@mathworks.com