Consider the following circuit;
The step response of this circuit may be expressed as follows;
where t=time (in seconds)
Write a function to calculate and return the value of Vout when given; the input voltage, the resistor values, capacitor value and time.
1 2 3 4 5 | #include<math.h> double circuit(double vin, double r1, double r2, double c, double t) { double r1_r2 = r1 + r2; return vin * r2 / (r1_r2) * (1 - exp(-t * (r1_r2 / (c * r1 * r2)))); } |
#include<math.h> double circuit(double vin, double r1, double r2, double c, double t) { double r1_r2 = r1 + r2; return vin * r2 / (r1_r2) * (1 - exp(-t * (r1_r2 / (c * r1 * r2)))); }
–EOF (The Ultimate Computing & Technology Blog) —
GD Star Rating
loading...
197 wordsloading...
Last Post: How to Ban and Make a User Unlike Your Facebook Page?
Next Post: Algorithm to Compute the Pascal Triangle's values