Your answer is one click away!

user3620862 February 2016
### Adding signals and separate them using MATLAB

I have two signals `m(t) = exp(-100*abs(t))`

and `c(t) = cos(2*pi*1000*t)`

.
I need to add them and then separate them using only a low pass filter (LPF) and a band pass filter (BPF) and plot the figures.

I wrote the code :

```
fs = 100*1000;
ts = 1/fs;
t = -0.1:ts:0.1-ts;
No = length(t);
m = exp(-100*abs(t));
c = cos(2*pi*1000*t);
g = m + c;
y = abs(g);
cutoff = 200;
[a b]= butter(5,2*cutoff*ts);
z = filter(a,b,y);
figure(1)
plot(t,m,t,z);
legend('Input Signal','Output Signal')
xlabel('time')
ylabel('amplitude')
title('Case Study')
```

Note that I used LPF `[a b] = butter(5,2*cutoff*ts);`

The problem is that the plot is shifted up and I think this is because of the DC component. Can you help me to edit the code and fix the shift? And should I use BPF? If yes, how?

Noel Segura February 2016

The offset you are getting is from using the abs value of `g`

. If instead of filtering `y`

you filter `g`

then you get a better result. The offset comes from the dc component of `abs(c)`

since this is not centered over zero, and any low pass filter will maintain this offset

Alessiox February 2016

In the `plot`

command, subtract the mean value, like this

`plot(t,m,t,z-mean(z));`

Hope this is what you're looking for

Asked in February 2016

Viewed 3,074 times

Voted 6

Answered 2 times

Viewed 3,074 times

Voted 6

Answered 2 times