Advertisement
hiddenGem

AC Generator and Resistor

Jul 16th, 2020
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
MatLab 0.99 KB | None | 0 0
  1. %% AC Generator and Resistor
  2. % Determines the RMS voltage, frequency, voltage at time t, and maximum
  3. % current of a circuit
  4.  
  5. % Inputs and Variables
  6. deltaV = input('What is the voltage output a*sin(b*t) where a and b are given in brackets?\n');
  7. fprintf('The equation for voltage output is deltaV = %isin(%it)\n', deltaV(1), deltaV(2))
  8. a = input('Is the above equation correct? Y/N \n', 's');
  9. while a == 'N'
  10.     deltaV = input('What is the voltage output a*sin(b*t) where a and b are given in brackets?\n');
  11.     a = input('Is the above equation correct? Y/N \n', 's');
  12. end
  13. t = input('What is the time t?\n');
  14. R = input('What is the resistance?\n');
  15.  
  16. % Outputs and Equations
  17. Vmax = deltaV(1);
  18. w = deltaV(2);
  19. f = w/(2*pi);
  20. Vt = deltaV(1)*sin(deltaV(2)*t);
  21. Vrms = Vmax/sqrt(2);
  22. I = Vmax/R;
  23. fprintf(['The RMS voltage, frequency, voltage at time t, and maximum current are:\n',...
  24.          '%.3e V, %.3f Hz, %.3e V, %.3f A'], Vrms, f, Vt, I );
  25.  
  26.  
  27. %{
  28. Note that the trig function is in radians
  29. %}
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement