Hello, dear friend, you can consult us at any time if you have any questions, add WeChat: THEend8_
LAB #2: CHARGING AND DISCHARGING OF A CAPACITOR IN A
RC CIRCUIT USING MATLAB
Objective
This lab features an RC circuit, which is one of the simplest circuits that uses a capacitor. You will study this
circuit and learn about the charging and discharging cycles of the capacitor using MATLAB as a tool.
Circuit
is the input voltage which is a periodic function with a period of 1 s.
Output
Plot for R = 1000 Ω, 4000 Ω , 8000 Ω.
The MATLAB output of this lab should be a SINGLE plot of for all three values of R with TWO
charging cycles and ONE discharge cycle. with all details directly shown on it (without any post-processing)
Submissions:
1) Calculations
All the basic calculations have to be typed-in and attached to the report generated by MATLAB (hand
written calculations will NOT be accepted)
2) Plot
Check the plot shown below. Your output should be exactly the same (WITHOUT the three “ENERGY
SYSTEMS” names on it)
3) Code
You should create and define a user-defined function “rcvalue” whose inputs are the value of R and C,
and the values passed by the function are voltage (v) and time (t)
a) Use %% to divide the code into THREE segments
b) The FIRST segment should have the following information as comments (use separate line for
each item)
i. Lab number, Lab Title
ii. Semester Name, Course Name (Course Code)
iii. Due Date
iv. Team Number
v. Student Number, Student Name (write all the students details in the same format)
c) The SECOND segment should have the complete code EXCEPT those parts mentioned in the
third segment.
d) The THIRD segment should have the “output plot code” and “the User-defined “rcvalue”
function code” (MATLAB does not publish code of the functions “rcvalue” , so for the sake of
the report put the code of the function “rcvalue” in comments of this segment after the output
plot code)
e) Use % to write "comments" for every line of code to explain the variables and purpose
f) Use "publish" to do your report in "pdf" format (this will be your Lab report along with the
supporting calculations, circuit diagram, algorithms, flow charts or tables)
Lab specific FUNCTIONS:
1) https://www.mathworks.com/help/matlab/ref/xlabel.html
2) https://www.mathworks.com/help/matlab/ref/ylabel.html
3) https://www.mathworks.com/help/matlab/ref/legend.html
4) https://www.mathworks.com/help/matlab/ref/text.html
5) https://www.mathworks.com/help/matlab/ref/title.html
6) https://www.mathworks.com/help/matlab/ref/axis.html
7) https://www.mathworks.com/help/matlab/ref/for.html
And also make use of the commands or functions used in previous lab/labs as per your needs.
MATLAB Version:
The latest version is MATLAB R2018b (Version 9.5), it is compatible with Windows, Mac and Linux.
For further systems requirements please refer to the following link
https://www.mathworks.com/support/sysreq.html
It is recommended to use the version MATLAB R2014b (Version 8.4) or after.
ONE Lab Report per TEAM, Maximum 3 Students per TEAM,
HAND-WRITTEN submissions will given a ZERO.
IMPORTANT:
In your m-file, you have to follow all the requirements mentioned above. If not, You will be deducted
points for every mistake.