diff options
Diffstat (limited to 'coursework17/RLC_script.m')
-rw-r--r-- | coursework17/RLC_script.m | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/coursework17/RLC_script.m b/coursework17/RLC_script.m new file mode 100644 index 0000000..42f0344 --- /dev/null +++ b/coursework17/RLC_script.m @@ -0,0 +1,27 @@ +h = 1e-4;
+R = 280;
+C = 4*10^(-6);
+L = 600*10^(-3);
+t0 = 0;
+tf = 0.04;
+N = round((tf-t0)/h);
+
+y = zeros(1, N);
+x = zeros(1, N);
+t = zeros(1, N);
+n = zeros(1, N);
+
+
+t(1) = t0;
+Vout = zeros(1, N);
+x(1) = 500*10^(-9);
+y(1) = 0;
+Vin = @(a)5;
+g = @(t,x,y) y;
+f = @(t,x,y)(Vin(t) - x/C - R*y)/L;
+for i = 1:N-1
+ [x(i+1), y(i+1)] = RK4second(t(i),x(i),y(i),h,g,f);
+ t(i+1) = t(i) + h;
+ Vout(i) = R*y(i);
+end
+plot(Vout);
|