Advertisement
hiddenGem

AC Circuit with R and C

Jul 16th, 2020
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
MatLab 0.85 KB | None | 0 0
  1. %% AC Circuit with R and C
  2. % Determines the RMS current, RMS voltage across the resistor and
  3. % capacitor, and the phase angle for the circuit
  4.  
  5. % Inputs and Variables
  6. C = input('What is the capacitance?\n');
  7. R = input('What is the resistance?\n');
  8. Vrms = input('What is the voltage RMS output?\n');
  9. f = input('What is the frequency? \n');
  10.  
  11. % Outputs and Equations
  12. Xc = 1/(2*pi*f*C);
  13. Irms = Vrms/sqrt(R^2+Xc^2);
  14. phi = atan(-Xc/R);
  15. VrRMS = Vrms*cos(phi);
  16. VcRMS = -Vrms*sin(phi);
  17. fprintf(['The RMS values for the current, voltage across resistor and capacitor, and phase angle are:\n',...
  18.          '%.3e A, %.3e V, %.3e V, %.3e rad'],Irms, VrRMS, VcRMS, phi)
  19. %{
  20. The trig functions and phase angle are calculated using radians. To change
  21. this adjust the trig functions to read atand, cosd, and sind. Also change
  22. the second fprintf line to read degrees
  23. %}
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement