From 3cf86838be8a410e3bf70d450d50db3d799026e9 Mon Sep 17 00:00:00 2001 From: Vasil Zlatanov Date: Thu, 23 Feb 2017 12:56:18 +0000 Subject: accept exerercise 3 form Alex --- coursework17/RLC_script.m | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 coursework17/RLC_script.m (limited to 'coursework17/RLC_script.m') 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); -- cgit v1.2.3-54-g00ecf