0

What does the commented line do? More specifically, why do I have the conv function times tpas value?

tstart=0;
tstop=0.1;
tpas=0.0001;
f=100;

t=tstart:tpas:tstop;
x=0+10*t;
subplot(3,1,1);
plot(t,x,'linewidth',2);
axis([0 0.1001 0 1]);
grid;

h=1*exp(-f*t);
subplot(3,1,2);
plot(t,h,'linewidth',2);
axis([0 0.1001 0 1]);
grid;

t2=2*tstart:tpas:2*tstop;

y=conv(x,h) * tpas; % what does this line do?

subplot(3,1,3);
plot(t2,y,'r','linewidth',2);
axis();
grid;

I posted the whole code for context but really I just need to know what happens when I multiply the convolution value with tpas.

Cris Luengo
  • 55,762
  • 10
  • 62
  • 120

1 Answers1

0

Your filter is h=1*exp(-f*t), which is sampled at time values t=tstart:tpas:tstop

The number of simples in your filter is (tstop-tstart)/tpas. The integral (just the sum of those samples) is therefore proportional to 1/tpas.

The convolution will multiply your signal by this factor, so the result is multiplied by tpas to correct it.

Matt Timmermans
  • 53,709
  • 3
  • 46
  • 87
  • "The integral (just the sum of those samples)" -- I guess it is exactly the difference between the integral and the sum that is being accounted for. – Cris Luengo Dec 08 '21 at 15:40