summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVasil Zlatanov <v@skozl.com>2017-02-20 15:07:11 +0000
committerVasil Zlatanov <v@skozl.com>2017-02-20 15:07:11 +0000
commit319681662d6598db00ddb371fab8a44a33fd126d (patch)
treeb4ff703cf1c6119466f61189fc5074124517a46d
parentf374fbf663a27d6a78c8fda6f160d39d4945e82c (diff)
downloade2-matlab-319681662d6598db00ddb371fab8a44a33fd126d.tar.gz
e2-matlab-319681662d6598db00ddb371fab8a44a33fd126d.tar.bz2
e2-matlab-319681662d6598db00ddb371fab8a44a33fd126d.zip
Improve skeleton for error
-rw-r--r--coursework17/error_script.m27
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));