Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- %% AC Generator and Resistor
- % Determines the RMS voltage, frequency, voltage at time t, and maximum
- % current of a circuit
- % Inputs and Variables
- deltaV = input('What is the voltage output a*sin(b*t) where a and b are given in brackets?\n');
- fprintf('The equation for voltage output is deltaV = %isin(%it)\n', deltaV(1), deltaV(2))
- a = input('Is the above equation correct? Y/N \n', 's');
- while a == 'N'
- deltaV = input('What is the voltage output a*sin(b*t) where a and b are given in brackets?\n');
- a = input('Is the above equation correct? Y/N \n', 's');
- end
- t = input('What is the time t?\n');
- R = input('What is the resistance?\n');
- % Outputs and Equations
- Vmax = deltaV(1);
- w = deltaV(2);
- f = w/(2*pi);
- Vt = deltaV(1)*sin(deltaV(2)*t);
- Vrms = Vmax/sqrt(2);
- I = Vmax/R;
- fprintf(['The RMS voltage, frequency, voltage at time t, and maximum current are:\n',...
- '%.3e V, %.3f Hz, %.3e V, %.3f A'], Vrms, f, Vt, I );
- %{
- Note that the trig function is in radians
- %}
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement