diff options
author | Vasil Zlatanov <v@skozl.com> | 2017-02-17 14:43:50 +0000 |
---|---|---|
committer | Vasil Zlatanov <v@skozl.com> | 2017-02-17 14:43:50 +0000 |
commit | abcd65d98b8a4830673d53eaa9665ad195b70b03 (patch) | |
tree | 8da09311592df2779f7da88d551e384fbe08ce7f /coursework17/ralston_script.m | |
parent | d4660bb996f1177593d90ac4c518c436fe621156 (diff) | |
download | e2-matlab-abcd65d98b8a4830673d53eaa9665ad195b70b03.tar.gz e2-matlab-abcd65d98b8a4830673d53eaa9665ad195b70b03.tar.bz2 e2-matlab-abcd65d98b8a4830673d53eaa9665ad195b70b03.zip |
work in progress solution for exercise 1 of coursework
Diffstat (limited to 'coursework17/ralston_script.m')
-rw-r--r-- | coursework17/ralston_script.m | 50 |
1 files changed, 50 insertions, 0 deletions
diff --git a/coursework17/ralston_script.m b/coursework17/ralston_script.m new file mode 100644 index 0000000..9db929f --- /dev/null +++ b/coursework17/ralston_script.m @@ -0,0 +1,50 @@ +% Vin = aI' + bI + +R = 0.5; % 0.5Ohm +L = 0.0015; % 1.5mH +data_points = 10000; + +% Go on for 8 time constants +time_constant = L/R; +step = time_constant*8/data_points; + +% Signal 1 Vin = 5.5V +Vin = @(t) 5.5 + 0*t; % 5.5V +current_initial=0; + +[t, Vout] = ralston(R, L, Vin, current_initial, step, data_points*step); +plot(t, Vout); + +% Signal 2a Vin = 5.5*exp(-t^2/r) V +Vin = @(t) 5.5*exp(-(t*160*10^(-6))^2) % 5.5V +current_initial=0; + +[t, Vout] = ralston(R, L, Vin, current_initial, step, data_points*step); +plot(t, Vout); + +% Signal 2b Vin = 5.5*exp(-t/r) +Vin = @(t) 5.5*exp(-t*160*10^(-6)) % 5.5V +current_initial=0; + +[t, Vout] = ralston(R, L, Vin, current_initial, step, data_points*step); +plot(t, Vout); + +% Signal 3 +T(1) = 20e-6; % 20us +T(2) = 450e-6; % 450us +T(3) = 1000e-6;% 1000us + +for j=1:3 + f = 1/T(j); + Vin = @(t) sin(2*pi*f*t); + [t, Vout] = ralston(R, L, Vin, current_initial, step, data_points*step); + plot(t, Vout); + + Vin = @(t) sawtooth(2*pi*f*t); + [t, Vout] = ralston(R, L, Vin, current_initial, step, data_points*step); + plot(t, Vout); + + Vin = @(t) square(2*pi*f*t); + [t, Vout] = ralston(R, L, Vin, current_initial, step, data_points*step); + plot(t, Vout); +end |