% RC circuit (series configuration) works as a filter (low-pass filter) clear all close all R=100; C=100e-6; % i-u representation, input u (source voltage), output y (voltage across C) % u=RC*y_dot + y => y_dot +y/(R*C) =u/(R*C) % ss representation % x_dot=-x/(R*C) +u/(R*C) % y=x % then x_dot=a*x + b*u; y=c*x+d*u a=-1/(R*C); b=1/(R*C); k=b/(-a); % =1; tau=1/(-a); % define the tf s=tf('s'); W=k/(1+tau*s); % plot the Bode diagrams bode(W); grid on hold on % plot the Bode asymptotic diagrams bodeas(W) grid on hold on % two inputs with different omega omega_1=10; omega_2=1000; T2=2*pi/omega_2; T1=2*pi/omega_1; time1=0:T1/50:5*T1; time2=0:T2/50:5*T2; u1=sin(omega_1*time1); u2=sin(omega_2*time2); y1=lsim(W,u1,time1); y2=lsim(W,u2,time2); % plot u and y figure hold on grid on plot(time1,u1,'-b','linewidth',2) plot(time1,y1,'-r','linewidth',2) legend('u_1','y_1') figure hold on grid on plot(time2,u2,'-b','linewidth',2) plot(time2,y2,'-r','linewidth',2) legend('u_2','y_2')