COMPGROUPS.NET | Search | Post Question | Groups | Stream | About | Register

### decimate() vs downsample()

• Follow

```Hello people

I stumbled upon some strange behaviour of the decimate()-Function. If I want to decimate a constant signal, I can assume that the decimated result reaches the same level? Than why is this not happening? Where didn't I get it?

x=[[0:1000] 1000*ones(1,100)];
y1=decimate(x,2);
y2=downsample(x,2);
clf;hold on;
plot(x,'g');
plot(y1,'r');
plot(y2,'b');
hold off;

This is just a quick and dirty hack -- enough to show what I mean.

Thanks and greetings!
```
 0

```"marvin" <mzenzes@mega2000.de> wrote in message <hmo7m2\$7gk\$1@fred.mathworks.com>...
> Hello people
>
> I stumbled upon some strange behaviour of the decimate()-Function. If I want to decimate a constant signal, I can assume that the decimated result reaches the same level? Than why is this not happening? Where didn't I get it?
>
> x=[[0:1000] 1000*ones(1,100)];
> y1=decimate(x,2);
> y2=downsample(x,2);
> clf;hold on;
> plot(x,'g');
> plot(y1,'r');
> plot(y2,'b');
> hold off;
>
> This is just a quick and dirty hack -- enough to show what I mean.
>
> Thanks and greetings!

well, does a careful look at

help decimate;
help downsample;
% not tell you the reason for your observation(?)...

us
```
 0

```"marvin" <mzenzes@mega2000.de> wrote in message <hmo7m2\$7gk\$1@fred.mathworks.com>...
> Hello people
>
> I stumbled upon some strange behaviour of the decimate()-Function. If I want to decimate a constant signal, I can assume that the decimated result reaches the same level? Than why is this not happening? Where didn't I get it?
>
> x=[[0:1000] 1000*ones(1,100)];
> y1=decimate(x,2);
> y2=downsample(x,2);
> clf;hold on;
> plot(x,'g');
> plot(y1,'r');
> plot(y2,'b');
> hold off;
>
> This is just a quick and dirty hack -- enough to show what I mean.
>
> Thanks and greetings!

Hi Marvin, That difference in behavior is fully expected. You have to keep in mind that decimate() is applying a lowpass filter. So decimation by a factor of two is the equivalent of convolving the input with a lowpass filter, and downsampling that convolution by two. On the other hand, downsample() merely downsamples the input (without filtering). Assume you use the default phase in downsample:

x=1:32;
downsample(x,2)

Note the outputs are integers and that each index in the output sequence is only affected by one index in the input, i.e. the 1st element of the downsampled sequence (output) only depends on the 1st element of the input, the 2nd element of the downsampled sequence only depends on the 3rd element of the input, and so on.

Now look at
x=1:32;
decimate(x,2)

Note the outputs are no longer integers. This is because each element of the output depends on more than one element in the input and the filter through convolution.

Hope that helps,
Wayne
```
 0

```Hey Wayne,

> Now look at
> x=1:32;
> decimate(x,2)
>
> Note the outputs are no longer integers. This is because each element of the output depends on more than one element in the input and the filter through convolution.
>
Ok, this is what the documentation says... But when I lowpass a constant signal/value -- like in my example 1000 -- shouldn't the lowpass filter reach 1000 aswell (after a specific time)? So in this example here, the lowpass-filter has a gain smaller than 1, which is not what i expected.
```
 0

3 Replies
840 Views

5/6/2013 11:08:06 AM