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.