From 319681662d6598db00ddb371fab8a44a33fd126d Mon Sep 17 00:00:00 2001 From: Vasil Zlatanov Date: Mon, 20 Feb 2017 15:07:11 +0000 Subject: Improve skeleton for error --- coursework17/error_script.m | 27 ++++++++++++++++++++------- 1 file changed, 20 insertions(+), 7 deletions(-) (limited to 'coursework17') diff --git a/coursework17/error_script.m b/coursework17/error_script.m index 29988bf..2744ba9 100644 --- a/coursework17/error_script.m +++ b/coursework17/error_script.m @@ -1,13 +1,26 @@ % This script will carry out error analysis -T = 150e-6; -f = 1/T; +R = 0.5; % 0.5Ohm +L = 0.0015; % 1.5mH -A=6; +data_points = 10000; -data_points=10e3; +% Go on for 8 time constants +time_constant = L/R; +step = time_constant*8/data_points; -% TODO find exact solution -exact = @(t) (); +T=150e-6; % 150us +f = 1/T; + +Vin = @(t) 6*cos(2*pi*f*t); +current_initial=0; + +current_exact = @(t) -- +Vout_exact = @(t) -- + +[time_array, Vout_array] = ralston(R, L, Vin, current_initial, step, data_points*step); for j=1:data_points - my_error = exact(time_array(j)) - Vout_array(j); + error_array(j) = Vout_exact(time_array(j)) - Vout_aray(j); +end + +plot(log(time_array),log(error_array)); -- cgit v1.2.3-54-g00ecf