# analysis of RC circuit using Matlab

I designed the circuit and obtained the desired outputs correctly. for for circuit it R = 1e3 , C= 0.15e-6, and f = 250 , ( for RC circuit) and in the second part it asks to increase the frequency to 2Kh that is R = 1e3 , C= 0.15e-6, and f = 2kh. now it asks Compare the gains and phases from question 1)d) and 1)e). Justify and explain similarities and/or differences I know the gain is Vout/Vin but the output looks pretty weird I have an idea but is there a difference between the two? I mean changing the frequency should change the gain or not? here is output/input waveform for circuit with f=250H and here is the one with f=2KH I also plotted the bode diagram for both circuits. f=250, and f=2kh respectively.  here is the code for Bode digram ( frequency domain) • That looks as expected (note the X-axis is log if that is part of your confusion). Why do you think it is odd? – JonRB Feb 24 '15 at 20:04
• @user65652 Gain is not the same. From the time-based plots, the first (at $f = 250$) has unity gain (the amplitudes of the purple and yellow plots are the same). But the second (at $f = 2000$) has the purple output at much lower amplitude than the yellow input. – Null Feb 24 '15 at 20:10
• Check the units on your bode plot... rad/s rather than cycles/ sec. – George Herold Feb 24 '15 at 20:10
• yes it does as there is no difference between the two bode plots. See my updated response as it is a slight tweak on the bode command to help show this. – JonRB Feb 24 '15 at 20:36
• By the way the title say RLC but all presented information is for RC – JonRB Feb 24 '15 at 21:05

You have two sets of waveforms

1) time domain

2) frequency domain

While you will see a difference between the two time domain plots (higher frequency resulting in a lower output, as expected) you will not between the two frequency domain plots

Why? it is how the matlab command works. You are not instructing Matlab to provide gain:phase at a particular frequency for the two frequency domain plots, you have essentially instructed Matlab to run a frequency sweep and resultant bode plot twice.

As a result you will not see any difference between these two plots.

--edit-- Based upon the presented matlab code:

The simplest solution to demonstrate a difference at different frequencies is to change the bode function call from

bode(monSysteme)

to

bode(monSysteme,{249,251})

and also:

bode(monSysteme,{1999,2001})

ie a specific frequency range, tight to the freq of interest.  PLEASE note, this isn't really needed as you can just read off of the original bode plot the magnitude at 250Hz and 2kHz and see a difference.

If a specific time domain reference point is needed & the desire isn't to read the result off of a bode plot then the BODE command isn't the correct command but lsim with a specific stim:

R=1e3;
C=0.15e-6;
num=1;
denum = [R*C 1];
m = tf(num,denum);

[u,t] = gensig('sin',1/250);
lsim(m,u,t)
figure
[u,t] = gensig('sin',1/2000);
lsim(m,u,t)  • Oh I see, I had an argument with my partner saying that. there must be a gain difference between the two circuits. he said frequency does not change the gain !! – user65652 Feb 24 '15 at 20:15
• could you edit the original post and post the script, with the carriage return delimiters – JonRB Feb 24 '15 at 20:20
• I added the bode diagram code in the original question – user65652 Feb 24 '15 at 20:25
• well I think I asked if I could find the gain through bode diagram. ( time domain) but the graphs are still in frequency domain – user65652 Feb 24 '15 at 20:41
• yes, as shown in the bode plot. It is a 1st order system. G = 1/sqrt(1 + (wRC)^2) & Phase = arctan(-wRC) Increase frequency of the input voltage and the output voltage amplitude decreases and the phase increases – JonRB Feb 24 '15 at 21:01