1

I am trying to model a RC filter's transfer function in order to know how an input signal is deformed when it reaches my sample. I first build the RC filter's transfer function to fit my experimental data but when I give an input signal to the lsim() function, it doesn't give me proper results, even for a sine.

Here's my piece of code:

R = 1000000; L = 1; C = 2.5*10^(-12);
G=tf([1], [R*C, 1]);
figure(1)
h=bodeplot(G,'b.-', opts);

f=10^(5);%signal frequency, Hz
tau=1/f;%Signal period, s
Tf=10*tau;%Signal duration
N=100000;%number of samples per period
Ts=tau/N;%Sampling time
figure(2);
[input_vector,t_vector]=gensig('sin',tau,Tf,Ts);
lsim(G,input_vector,t_vector);

For a sine at 100kHz, I should be getting -0.25dB of attenuation, therefore about 2% on voltage. Here it gets me a result 45% lower than my input signal.

Exeko
  • 56
  • 7

2 Answers2

0

It must be your intuition about some detail. I get exactly the proper results expected by running your code.

enter image description here

percusse
  • 3,006
  • 1
  • 14
  • 28
  • When i plot the bodeplot(), it gives me the attenuation in dB, not the magnitude like this... and for the values of R and C I am giving, it gives me 0.25 dB attenuation at 1kHz. What version of Matlab are you using? – Exeko Jan 18 '18 at 02:23
  • @Exeko you can right click and change the units. matlab 2017a – percusse Jan 18 '18 at 02:40
0

The problem came from the conversion from rad/s to Hz, which introduces a 2*pi factor, shifting the attenuation curve to the left.

Exeko
  • 56
  • 7