Need help to solve of Matlab code

Click For Summary
SUMMARY

The discussion focuses on solving a MATLAB coding problem involving the charging of a capacitor in a series circuit with a resistor and a battery. The formula used is Q(t) = CV(1 − e−t/RC), with given values of V = 9 volts, R = 4 ohms, and C = 1 farad. Participants are tasked with writing a program to monitor the charge every 0.1 seconds until it exceeds 8 units, and then modifying the program to display the charge only while it remains below 8 units. Key coding techniques include constructing a time vector and using element-wise operations.

PREREQUISITES
  • Understanding of MATLAB programming
  • Familiarity with capacitor charging equations
  • Knowledge of time vector construction in MATLAB
  • Experience with loops and conditional statements in programming
NEXT STEPS
  • Learn MATLAB time vector creation techniques
  • Study element-wise operations in MATLAB
  • Explore MATLAB for loops and if statements
  • Investigate capacitor charging dynamics and related equations
USEFUL FOR

This discussion is beneficial for students preparing for exams in electrical engineering, MATLAB programmers, and anyone interested in simulating capacitor behavior in circuits.

zayodi
Messages
1
Reaction score
0
When a resistor (R), capacitor (C) and battery (V) are connected in series,
a charge Q builds up on the capacitor according to the formula
Q(t) = CV(1 − e−t/RC)
if there is no charge on the capacitor at time t =0. The problem is to monitor the
charge on the capacitor every 0.1 seconds in order to detect when it reaches a
level of 8 units of charge, given that V =9, R=4 and C =1. Write a program which
displays the time and charge every 0.1 seconds until the charge first exceeds
8 units (i.e. the last charge displayed must exceed 8). Once you have done this,
rewrite the program to display the charge only while it is strictly less than 8 units.

Dear all anyone can help me to solve the above quesion on Matlab coz i have exam on it tomorrow

waiting for support ASAP
 
Physics news on Phys.org
you must first construct a time vector of the numerical values

1. t = ti:dt:tf

where ti is initial time, dt is the change in time (it can't be infinitesimally small on a computer like it can in analytical mathematics, and the closer you go to 0 the more computationally expensive it is).

2. user your equation. don't forget to put a '.' in front of operators on a vector.

other than that, you have to get creative with your code and indexing (possibly with a for loop and/or some if statements) , but that's all I should probably give you. Good luck.
 

Similar threads

  • · Replies 4 ·
Replies
4
Views
2K
  • · Replies 6 ·
Replies
6
Views
4K
  • · Replies 41 ·
2
Replies
41
Views
10K
  • · Replies 3 ·
Replies
3
Views
5K
  • · Replies 8 ·
Replies
8
Views
3K
  • · Replies 9 ·
Replies
9
Views
3K
  • · Replies 18 ·
Replies
18
Views
4K
  • · Replies 9 ·
Replies
9
Views
5K
  • · Replies 8 ·
Replies
8
Views
2K
  • · Replies 6 ·
Replies
6
Views
2K