diff options
author | Vasil Zlatanov <v@skozl.com> | 2017-02-23 12:56:18 +0000 |
---|---|---|
committer | Vasil Zlatanov <v@skozl.com> | 2017-02-23 12:56:18 +0000 |
commit | 3cf86838be8a410e3bf70d450d50db3d799026e9 (patch) | |
tree | 66707e6fbbadd72cb60aafa63e22e2a233374a89 /coursework17/RLC_script.m | |
parent | 0cf1fa44a5e8d35ce263954bd53bb94b7b0f9099 (diff) | |
download | e2-matlab-3cf86838be8a410e3bf70d450d50db3d799026e9.tar.gz e2-matlab-3cf86838be8a410e3bf70d450d50db3d799026e9.tar.bz2 e2-matlab-3cf86838be8a410e3bf70d450d50db3d799026e9.zip |
accept exerercise 3 form Alex
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);
|