# how to remove dc component of a vector under matlab

Status
Not open for further replies.

#### kiya

##### Newbie level 2 remove dc component

i just read some code and don't quite understand its theory.
i am new bie in DSP area. that is

Code:
% force xx as a column vector
xx = xx(:);
% remove dc component
xx = conv(xx,ones(3,1))/3;
xx = xx-mean(xx);

anybody can explain for me about the sencond sentence? what does it used for? and what's the theory it is used?
thanks a lot!!

#### GroundCtrl

##### Junior Member level 3 dc remove matlab

The sentence

xx = conv(xx,ones(3,1))/3;

have no meaning for dc component removing. This term looks like sliding average for removing of high-frequency signal components (or noise). The dc removing itself describing by third term (where mean(xx) - dc bias):

xx = xx-mean(xx);

And nothing but this!!!

#### kiya

##### Newbie level 2 how to remove dc of signal matlab

yes, you are right. thank you!
but can you explain also about
Code:
xx = conv(xx,ones(3,1))/3;
what's ones(3,1) stand for? as i know, it is just a vector with [1;1;1].
and how to calculate the features of this filter?

#### GroundCtrl

##### Junior Member level 3 remove dc matlab

You are little wrong. The sentence xx = conv(xx,ones(3,1))/3 is the convolution of input sequence and vector [1/3; 1/3; 1/3]. As I mentioned this sentence looks like sliding average for noice removing.

What kind of features do you want to calculate?

Z-transform: H(z) = 1/3+(z^-1)/3+(z^-2)/3.
Phase-Frequency responce: W(w) = 1/3+exp(-jw)/3+exp(-2jw)/3 = H(exp(jw)).

All features (pass-band, phase delay, side-lobes attenuation and so on) of this filter calculated from this responce.

Status
Not open for further replies.