diff options
Diffstat (limited to 'coursework17')
-rw-r--r-- | coursework17/error_script.m | 27 |
1 files changed, 20 insertions, 7 deletions
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)); |