diff options
author | MK2020 <kivabi14@gmail.com> | 2017-03-14 03:26:42 +0000 |
---|---|---|
committer | MK2020 <kivabi14@gmail.com> | 2017-03-14 03:26:42 +0000 |
commit | 50a968d642ae703e5205ab283c1c230e5f0e2c59 (patch) | |
tree | 819d7d62e5430e9ed98360baae3990d468a1151c /Part 1 | |
parent | 5a50d1d0ca987df654f7a67d6ac72b8077f5acf4 (diff) | |
download | NumericalAnalysis-50a968d642ae703e5205ab283c1c230e5f0e2c59.tar.gz NumericalAnalysis-50a968d642ae703e5205ab283c1c230e5f0e2c59.zip |
graphs done
Diffstat (limited to 'Part 1')
57 files changed, 171 insertions, 160 deletions
diff --git a/Part 1/Figures/heun_exponential1.fig b/Part 1/Figures/heun_exponential1.fig Binary files differnew file mode 100644 index 0000000..0827d4a --- /dev/null +++ b/Part 1/Figures/heun_exponential1.fig diff --git a/Part 1/Figures/heun_exponential2.fig b/Part 1/Figures/heun_exponential2.fig Binary files differnew file mode 100644 index 0000000..44b7d21 --- /dev/null +++ b/Part 1/Figures/heun_exponential2.fig diff --git a/Part 1/Figures/heun_heaviside.fig b/Part 1/Figures/heun_heaviside.fig Binary files differnew file mode 100644 index 0000000..b36922c --- /dev/null +++ b/Part 1/Figures/heun_heaviside.fig diff --git a/Part 1/Figures/heun_heaviside_current.fig b/Part 1/Figures/heun_heaviside_current.fig Binary files differnew file mode 100644 index 0000000..a10a5d4 --- /dev/null +++ b/Part 1/Figures/heun_heaviside_current.fig diff --git a/Part 1/Figures/heun_sawtooth(T=0.000015).fig b/Part 1/Figures/heun_sawtooth(T=0.000015).fig Binary files differnew file mode 100644 index 0000000..fd69242 --- /dev/null +++ b/Part 1/Figures/heun_sawtooth(T=0.000015).fig diff --git a/Part 1/Figures/heun_sawtooth(T=0.0004).fig b/Part 1/Figures/heun_sawtooth(T=0.0004).fig Binary files differnew file mode 100644 index 0000000..468ce49 --- /dev/null +++ b/Part 1/Figures/heun_sawtooth(T=0.0004).fig diff --git a/Part 1/Figures/heun_sawtooth(T=0.0011).fig b/Part 1/Figures/heun_sawtooth(T=0.0011).fig Binary files differnew file mode 100644 index 0000000..bb1735c --- /dev/null +++ b/Part 1/Figures/heun_sawtooth(T=0.0011).fig diff --git a/Part 1/Figures/heun_sawtooth.fig b/Part 1/Figures/heun_sawtooth.fig Binary files differnew file mode 100644 index 0000000..349917f --- /dev/null +++ b/Part 1/Figures/heun_sawtooth.fig diff --git a/Part 1/Figures/heun_sawtoothwave(T=0.00015).fig b/Part 1/Figures/heun_sawtoothwave(T=0.00015).fig Binary files differnew file mode 100644 index 0000000..8dbf09d --- /dev/null +++ b/Part 1/Figures/heun_sawtoothwave(T=0.00015).fig diff --git a/Part 1/Figures/heun_sinewave(T=0.000015).fig b/Part 1/Figures/heun_sinewave(T=0.000015).fig Binary files differnew file mode 100644 index 0000000..e436456 --- /dev/null +++ b/Part 1/Figures/heun_sinewave(T=0.000015).fig diff --git a/Part 1/Figures/heun_sinewave(T=0.00015)fig.fig b/Part 1/Figures/heun_sinewave(T=0.00015)fig.fig Binary files differnew file mode 100644 index 0000000..f9306fe --- /dev/null +++ b/Part 1/Figures/heun_sinewave(T=0.00015)fig.fig diff --git a/Part 1/Figures/heun_sinewave(T=0.0004).fig b/Part 1/Figures/heun_sinewave(T=0.0004).fig Binary files differnew file mode 100644 index 0000000..1b9a5c7 --- /dev/null +++ b/Part 1/Figures/heun_sinewave(T=0.0004).fig diff --git a/Part 1/Figures/heun_sinewave(T=0.0011).fig b/Part 1/Figures/heun_sinewave(T=0.0011).fig Binary files differnew file mode 100644 index 0000000..213f786 --- /dev/null +++ b/Part 1/Figures/heun_sinewave(T=0.0011).fig diff --git a/Part 1/Figures/heun_squarewave(T=0.000015).fig b/Part 1/Figures/heun_squarewave(T=0.000015).fig Binary files differnew file mode 100644 index 0000000..900e57d --- /dev/null +++ b/Part 1/Figures/heun_squarewave(T=0.000015).fig diff --git a/Part 1/Figures/heun_squarewave(T=0.00015).fig b/Part 1/Figures/heun_squarewave(T=0.00015).fig Binary files differnew file mode 100644 index 0000000..132f006 --- /dev/null +++ b/Part 1/Figures/heun_squarewave(T=0.00015).fig diff --git a/Part 1/Figures/heun_squarewave(T=0.0011).fig b/Part 1/Figures/heun_squarewave(T=0.0011).fig Binary files differnew file mode 100644 index 0000000..6c26ef7 --- /dev/null +++ b/Part 1/Figures/heun_squarewave(T=0.0011).fig diff --git a/Part 1/Figures/heun_squarewave(T=0.0040).fig b/Part 1/Figures/heun_squarewave(T=0.0040).fig Binary files differnew file mode 100644 index 0000000..531757c --- /dev/null +++ b/Part 1/Figures/heun_squarewave(T=0.0040).fig diff --git a/Part 1/Figures/heun_squarewave.fig b/Part 1/Figures/heun_squarewave.fig Binary files differnew file mode 100644 index 0000000..0db402f --- /dev/null +++ b/Part 1/Figures/heun_squarewave.fig diff --git a/Part 1/Figures/midpoint_exponential1.fig b/Part 1/Figures/midpoint_exponential1.fig Binary files differnew file mode 100644 index 0000000..595167f --- /dev/null +++ b/Part 1/Figures/midpoint_exponential1.fig diff --git a/Part 1/Figures/midpoint_exponential2.fig b/Part 1/Figures/midpoint_exponential2.fig Binary files differnew file mode 100644 index 0000000..45a5e57 --- /dev/null +++ b/Part 1/Figures/midpoint_exponential2.fig diff --git a/Part 1/Figures/midpoint_heaviside.fig b/Part 1/Figures/midpoint_heaviside.fig Binary files differnew file mode 100644 index 0000000..e5f6332 --- /dev/null +++ b/Part 1/Figures/midpoint_heaviside.fig diff --git a/Part 1/Figures/midpoint_sawtooth(T=0.000015).fig b/Part 1/Figures/midpoint_sawtooth(T=0.000015).fig Binary files differnew file mode 100644 index 0000000..9c95213 --- /dev/null +++ b/Part 1/Figures/midpoint_sawtooth(T=0.000015).fig diff --git a/Part 1/Figures/midpoint_sawtooth(T=0.00015).fig b/Part 1/Figures/midpoint_sawtooth(T=0.00015).fig Binary files differnew file mode 100644 index 0000000..c4a0ff7 --- /dev/null +++ b/Part 1/Figures/midpoint_sawtooth(T=0.00015).fig diff --git a/Part 1/Figures/midpoint_sawtooth(T=0.0004).fig b/Part 1/Figures/midpoint_sawtooth(T=0.0004).fig Binary files differnew file mode 100644 index 0000000..69e7215 --- /dev/null +++ b/Part 1/Figures/midpoint_sawtooth(T=0.0004).fig diff --git a/Part 1/Figures/midpoint_sawtooth(T=0.0011).fig b/Part 1/Figures/midpoint_sawtooth(T=0.0011).fig Binary files differnew file mode 100644 index 0000000..3cf8687 --- /dev/null +++ b/Part 1/Figures/midpoint_sawtooth(T=0.0011).fig diff --git a/Part 1/Figures/midpoint_sinewave(T=0.000015).fig b/Part 1/Figures/midpoint_sinewave(T=0.000015).fig Binary files differnew file mode 100644 index 0000000..fd56077 --- /dev/null +++ b/Part 1/Figures/midpoint_sinewave(T=0.000015).fig diff --git a/Part 1/Figures/midpoint_sinewave(T=0.00015).fig b/Part 1/Figures/midpoint_sinewave(T=0.00015).fig Binary files differnew file mode 100644 index 0000000..1993081 --- /dev/null +++ b/Part 1/Figures/midpoint_sinewave(T=0.00015).fig diff --git a/Part 1/Figures/midpoint_sinewave(T=0.0004).fig b/Part 1/Figures/midpoint_sinewave(T=0.0004).fig Binary files differnew file mode 100644 index 0000000..6f1445a --- /dev/null +++ b/Part 1/Figures/midpoint_sinewave(T=0.0004).fig diff --git a/Part 1/Figures/midpoint_sinewave(T=0.0011).fig b/Part 1/Figures/midpoint_sinewave(T=0.0011).fig Binary files differnew file mode 100644 index 0000000..4ddf9e7 --- /dev/null +++ b/Part 1/Figures/midpoint_sinewave(T=0.0011).fig diff --git a/Part 1/Figures/midpoint_squarewave(T=0.000015).fig b/Part 1/Figures/midpoint_squarewave(T=0.000015).fig Binary files differnew file mode 100644 index 0000000..c1e06c7 --- /dev/null +++ b/Part 1/Figures/midpoint_squarewave(T=0.000015).fig diff --git a/Part 1/Figures/midpoint_squarewave(T=0.00015).fig b/Part 1/Figures/midpoint_squarewave(T=0.00015).fig Binary files differnew file mode 100644 index 0000000..a72d953 --- /dev/null +++ b/Part 1/Figures/midpoint_squarewave(T=0.00015).fig diff --git a/Part 1/Figures/midpoint_squarewave(T=0.0004).fig b/Part 1/Figures/midpoint_squarewave(T=0.0004).fig Binary files differnew file mode 100644 index 0000000..cec47ff --- /dev/null +++ b/Part 1/Figures/midpoint_squarewave(T=0.0004).fig diff --git a/Part 1/Figures/midpoint_squarewave(T=0.0011).fig b/Part 1/Figures/midpoint_squarewave(T=0.0011).fig Binary files differnew file mode 100644 index 0000000..5d2f8a1 --- /dev/null +++ b/Part 1/Figures/midpoint_squarewave(T=0.0011).fig diff --git a/Part 1/Figures/ralson_exponential1.fig b/Part 1/Figures/ralson_exponential1.fig Binary files differnew file mode 100644 index 0000000..7bd6929 --- /dev/null +++ b/Part 1/Figures/ralson_exponential1.fig diff --git a/Part 1/Figures/ralson_heaviside.fig b/Part 1/Figures/ralson_heaviside.fig Binary files differnew file mode 100644 index 0000000..36dfbba --- /dev/null +++ b/Part 1/Figures/ralson_heaviside.fig diff --git a/Part 1/Figures/ralson_sinewave.fig b/Part 1/Figures/ralson_sinewave.fig Binary files differnew file mode 100644 index 0000000..b94282b --- /dev/null +++ b/Part 1/Figures/ralson_sinewave.fig diff --git a/Part 1/Figures/ralston_exponential1.fig b/Part 1/Figures/ralston_exponential1.fig Binary files differnew file mode 100644 index 0000000..f764a91 --- /dev/null +++ b/Part 1/Figures/ralston_exponential1.fig diff --git a/Part 1/Figures/ralston_exponential2.fig b/Part 1/Figures/ralston_exponential2.fig Binary files differnew file mode 100644 index 0000000..483ce53 --- /dev/null +++ b/Part 1/Figures/ralston_exponential2.fig diff --git a/Part 1/Figures/ralston_sawtooth(T=0.000015).fig b/Part 1/Figures/ralston_sawtooth(T=0.000015).fig Binary files differnew file mode 100644 index 0000000..f6479f6 --- /dev/null +++ b/Part 1/Figures/ralston_sawtooth(T=0.000015).fig diff --git a/Part 1/Figures/ralston_sawtooth(T=0.00015).fig b/Part 1/Figures/ralston_sawtooth(T=0.00015).fig Binary files differnew file mode 100644 index 0000000..cc6a913 --- /dev/null +++ b/Part 1/Figures/ralston_sawtooth(T=0.00015).fig diff --git a/Part 1/Figures/ralston_sawtooth(T=0.0004).fig b/Part 1/Figures/ralston_sawtooth(T=0.0004).fig Binary files differnew file mode 100644 index 0000000..e310eef --- /dev/null +++ b/Part 1/Figures/ralston_sawtooth(T=0.0004).fig diff --git a/Part 1/Figures/ralston_sawtooth(T=0.0011).fig b/Part 1/Figures/ralston_sawtooth(T=0.0011).fig Binary files differnew file mode 100644 index 0000000..bc7ce20 --- /dev/null +++ b/Part 1/Figures/ralston_sawtooth(T=0.0011).fig diff --git a/Part 1/Figures/ralston_sawtooth.fig b/Part 1/Figures/ralston_sawtooth.fig Binary files differnew file mode 100644 index 0000000..52ce8a6 --- /dev/null +++ b/Part 1/Figures/ralston_sawtooth.fig diff --git a/Part 1/Figures/ralston_sinewave(T=0.000015).fig b/Part 1/Figures/ralston_sinewave(T=0.000015).fig Binary files differnew file mode 100644 index 0000000..6496a4b --- /dev/null +++ b/Part 1/Figures/ralston_sinewave(T=0.000015).fig diff --git a/Part 1/Figures/ralston_sinewave(T=0.00015).fig b/Part 1/Figures/ralston_sinewave(T=0.00015).fig Binary files differnew file mode 100644 index 0000000..11b01ec --- /dev/null +++ b/Part 1/Figures/ralston_sinewave(T=0.00015).fig diff --git a/Part 1/Figures/ralston_sinewave(T=0.0004).fig b/Part 1/Figures/ralston_sinewave(T=0.0004).fig Binary files differnew file mode 100644 index 0000000..af9dc00 --- /dev/null +++ b/Part 1/Figures/ralston_sinewave(T=0.0004).fig diff --git a/Part 1/Figures/ralston_sinewave(T=0.0011).fig b/Part 1/Figures/ralston_sinewave(T=0.0011).fig Binary files differnew file mode 100644 index 0000000..747f340 --- /dev/null +++ b/Part 1/Figures/ralston_sinewave(T=0.0011).fig diff --git a/Part 1/Figures/ralston_squarewave(T=0.000015).fig b/Part 1/Figures/ralston_squarewave(T=0.000015).fig Binary files differnew file mode 100644 index 0000000..3f7a4c5 --- /dev/null +++ b/Part 1/Figures/ralston_squarewave(T=0.000015).fig diff --git a/Part 1/Figures/ralston_squarewave(T=0.00015).fig b/Part 1/Figures/ralston_squarewave(T=0.00015).fig Binary files differnew file mode 100644 index 0000000..b1ee1e9 --- /dev/null +++ b/Part 1/Figures/ralston_squarewave(T=0.00015).fig diff --git a/Part 1/Figures/ralston_squarewave(T=0.0004).fig b/Part 1/Figures/ralston_squarewave(T=0.0004).fig Binary files differnew file mode 100644 index 0000000..f5fa280 --- /dev/null +++ b/Part 1/Figures/ralston_squarewave(T=0.0004).fig diff --git a/Part 1/Figures/ralston_squarewave(T=0.0011).fig b/Part 1/Figures/ralston_squarewave(T=0.0011).fig Binary files differnew file mode 100644 index 0000000..2286205 --- /dev/null +++ b/Part 1/Figures/ralston_squarewave(T=0.0011).fig diff --git a/Part 1/Figures/ralston_squarewave.fig b/Part 1/Figures/ralston_squarewave.fig Binary files differnew file mode 100644 index 0000000..b9f199b --- /dev/null +++ b/Part 1/Figures/ralston_squarewave.fig diff --git a/Part 1/heun_script.m b/Part 1/heun_script.m index fdf9a62..012c75a 100644 --- a/Part 1/heun_script.m +++ b/Part 1/heun_script.m @@ -14,7 +14,7 @@ Vout = zeros(1, N); current = zeros(1,N);
%input voltage
-% step function of 5 volt
+% step function of 3.5 volt
Vin = @(t)3.5*heaviside(t);
%the initial condition
@@ -40,6 +40,12 @@ xlabel({'Time', '(seconds)'}); ylabel({'V_{out}', '(volt)'});
title('(Heaviside) V_{out} versus time');
+figure(8);
+plot(t, current);
+xlabel({'Time', '(seconds)'});
+ylabel({'V_{out}', '(volt)'});
+title('V_{out} versus time (Heaviside)');
+
%---------------------------------------------------------------------------------------------
%initailise the circuits at the top
@@ -73,12 +79,10 @@ figure(2); plot(Vout);
xlabel({'Time', '(seconds)'});
ylabel({'V_{out}', '(volt)'});
-title('(Exponential #1) V_{out} versus time');
+title('V_{out} versus time (Exponential square function #1)');
%-----------------------------------------------------------------------------------------------
-%initailise the circuits at the top
-
%initailise the container at the top
%input voltage
@@ -108,10 +112,10 @@ figure(3); plot(Vout);
xlabel({'Time', '(seconds)'});
ylabel({'V_{out}', '(volt)'});
-title('#(Exponential #2) V_{out} versus time');
+title('V_{out} versus time (Exponential #2)');
-%-------------------------------------------------------------------------------------------
+% %-------------------------------------------------------------------------------------------
%initailise the circuits at the top
@@ -126,7 +130,9 @@ current = zeros(1,N); %input voltage
% step function of 5 volt
-Vin = @(t)4*sin(2*pi*6000*t);
+% T= 0.00015, 0.000015, 0.0004, 0.0011
+T = 0.0011;
+Vin = @(t)4*sin(2*pi*t/T);
%the initial condition
t(1) = 0;
@@ -149,7 +155,7 @@ figure(4); plot(Vout);
xlabel({'Time', '(seconds)'});
ylabel({'V_{out}', '(volt)'});
-title('(Sine wave) V_{out} versus time ');
+title('V_{out} versus time (T=0.0011)(Sine wave)');
%-----------------------------------------------------------------------------------------
@@ -162,7 +168,7 @@ title('(Sine wave) V_{out} versus time '); %input voltage
% step function of 5 volt
A = 4;
-T = 0.0015;
+T = 0.0011;
Vin = @(t) A * square(2*pi*t/T);
@@ -187,7 +193,7 @@ figure(5); plot(Vout);
xlabel({'Time', '(seconds)'});
ylabel({'V_{out}', '(volt)'});
-title('(Square wave) V_{out} versus time');
+title('V_{out} versus time (T=0.0011) (Square wave)');
%--------------------------------------------------------------------------------------
%initailise the circuits at the top
@@ -197,7 +203,7 @@ title('(Square wave) V_{out} versus time'); %input voltage
% step function of 5 volt
A = 4;
-T = 0.0015;
+T = 0.000015;
Vin = @(t) A * sawtooth(2*pi*t/T);
@@ -222,6 +228,6 @@ figure(6); plot(Vout);
xlabel({'Time', '(seconds)'});
ylabel({'V_{out}', '(volt)'});
-title('(Sawtooth wave) V_{out} versus time');
+title('V_{out} versus time (T=0.0011) (Sawtooth wave)');
end
\ No newline at end of file diff --git a/Part 1/midpoint_script.m b/Part 1/midpoint_script.m index 35ace43..196cb90 100644 --- a/Part 1/midpoint_script.m +++ b/Part 1/midpoint_script.m @@ -3,99 +3,104 @@ ts = 0; % set initial value of x_0 is = 0;
h = 0.0001; % set step-size
tf = 0.03; % stop here
+
R = 0.5;
L = 0.0015;
-vin = @(t) 3.5;
-func = @(t, iout) (vin(t) - iout*R) / L; % define func
-[t, iout ] = midpoint(func, ts, tf, is, h);
-
-vout = vin(t) - iout * R;
-plot(t,vout);
-xlabel({'Time', '(seconds)'});
-ylabel({'V_{out}', '(volt)'});
-title('V_{out} versus time (original function)');
+% vin = @(t) 3.5;
+% func = @(t, iout) (vin(t) - iout*R) / L; % define func
+% [t, iout ] = midpoint(func, ts, tf, is, h);
+%
+% vout = vin(t) - iout * R;
+% figure(1);
+% plot(t,vout);
+% xlabel({'Time', '(seconds)'});
+% ylabel({'V_{out}', '(volt)'});
+% title('V_{out} versus time (Heaviside)');
+% %____________________________________________________________________
+% h = 0.0001;
+% tf = 0.03;
+% figure;
+% A = 3.5;
+% tau = 0.00015;
+%
+% vin = @(t) A * exp(-t.^2/tau);
+% func = @(t, iout) (vin(t) - iout*R) / L; % define func
+% [t, iout ] = midpoint(func, ts, tf, is, h);
+%
+% vout = vin(t) - iout * R;
+% figure(2);
+% plot(t,vout);
+% xlabel({'Time', '(seconds)'});
+% ylabel({'V_{out}', '(volt)'});
+% title('V_{out} versus time (Exponential square function #1)');
%____________________________________________________________________
-h = 0.0001;
-tf = 0.03;
-figure;
-A = 3.5;
-tau = 0.000150;
-
-vin = @(t) A * exp(-t.^2/tau);
-func = @(t, iout) (vin(t) - iout*R) / L; % define func
-[t, iout ] = midpoint(func, ts, tf, is, h);
+% h = 0.0001;
+% tf = 0.03;
+% figure;
+% A = 3.5;
+% tau = 0.00015;
+%
+% vin = @(t) A * exp(-t/tau);
+% func = @(t, iout) (vin(t) - iout*R) / L; % define func
+% [t, iout ] = midpoint(func, ts, tf, is, h);
+%
+% vout = vin(t) - iout * R;
+% figure(3);
+% plot(t,vout);
+% xlabel({'Time', '(seconds)'});
+% ylabel({'V_{out}', '(volt)'});
+% title('V_{out} versus time (Exponential function #2)');
-vout = vin(t) - iout * R;
-plot(t,vout);
-xlabel({'Time', '(seconds)'});
-ylabel({'V_{out}', '(volt)'});
-title('V_{out} versus time (exponential square funtion)');
%____________________________________________________________________
-h = 0.0001;
-tf = 0.03;
-figure;
-A = 3.5;
-tau = 0.000150;
-
-vin = @(t) A * exp(-t/tau);
-func = @(t, iout) (vin(t) - iout*R) / L; % define func
-[t, iout ] = midpoint(func, ts, tf, is, h);
-
-vout = vin(t) - iout * R;
-plot(t,vout);
-xlabel({'Time', '(seconds)'});
-ylabel({'V_{out}', '(volt)'});
-title('V_{out} versus time (exponential function)');
-
+% h = 0.0001;
+% tf = 0.03;
+% figure;
+% A = 4;
+% T = 0.0011;
+%
+% vin = @(t) A * sin(2*pi*t/T);
+% func = @(t, iout) (vin(t) - iout*R) / L; % define func
+% [t, iout ] = midpoint(func, ts, tf, is, h);
+%
+% vout = vin(t) - iout * R;
+% figure(4);
+% plot(t,vout);
+% xlabel({'Time', '(seconds)'});
+% ylabel({'V_{out}', '(volt)'});
+% title('V_{out} versus time (T=0.0011) (Sine wave)');
%____________________________________________________________________
-h = 0.0001;
-tf = 0.03;
-figure;
-A = 4;
-T = 0.0015;
-
-vin = @(t) A * sin(2*pi*t/T);
-func = @(t, iout) (vin(t) - iout*R) / L; % define func
-[t, iout ] = midpoint(func, ts, tf, is, h);
-
-vout = vin(t) - iout * R;
-plot(t,vout);
-xlabel({'Time', '(seconds)'});
-ylabel({'V_{out}', '(volt)'});
-title('V_{out} versus time (sine function)');
-%____________________________________________________________________
-h = 0.0001;
-tf = 0.03;
-figure;
-A = 4;
-T = 0.0015;
-
-vin = @(t) A * square(2*pi*t/T);
-func = @(t, iout) (vin(t) - iout*R) / L; % define func
-[t, iout ] = midpoint(func, ts, tf, is, h);
-
-vout = vin(t) - iout * R;
-plot(t,vout);
-xlabel({'Time', '(seconds)'});
-ylabel({'V_{out}', '(volt)'});
-title('V_{out} versus time (square function)');
+% h = 0.0001;
+% tf = 0.03;
+% A = 4;
+% T = 0.0011;
+%
+% vin = @(t) A * square(2*pi*t/T);
+% func = @(t, iout) (vin(t) - iout*R) / L; % define func
+% [t, iout ] = midpoint(func, ts, tf, is, h);
+%
+% vout = vin(t) - iout * R;
+% figure(5);
+% plot(t,vout);
+% xlabel({'Time', '(seconds)'});
+% ylabel({'V_{out}', '(volt)'});
+% title('V_{out} versus time (T=0.0011) (Square wave)');
%____________________________________________________________________
h = 0.0001;
tf = 0.03;
-figure;
A = 4;
-T = 0.0015;
+T = 0.0011;
vin = @(t) A * sawtooth(2*pi*t/T);
func = @(t, iout) (vin(t) - iout*R) / L; % define func
[t, iout ] = midpoint(func, ts, tf, is, h);
vout = vin(t) - iout * R;
+figure(6);
plot(t,vout);
xlabel({'Time', '(seconds)'});
ylabel({'V_{out}', '(volt)'});
-title('V_{out} versus time (sawtooth function)');
+title('V_{out} versus time (T=0.0011) (Sawtooth wave)');
diff --git a/Part 1/midpoint_squarewave(T=0.00015).fig b/Part 1/midpoint_squarewave(T=0.00015).fig Binary files differnew file mode 100644 index 0000000..a032340 --- /dev/null +++ b/Part 1/midpoint_squarewave(T=0.00015).fig diff --git a/Part 1/ralston_script.m b/Part 1/ralston_script.m index 91da2a9..4e9ee70 100644 --- a/Part 1/ralston_script.m +++ b/Part 1/ralston_script.m @@ -6,86 +6,86 @@ tf = 0.03; % stop here R = 0.5;
L = 0.0015;
-vin = @(t) 3.5;
-func = @(t, iout) (vin(t) - iout*R) / L; % define func
-[t, iout ] = ralston(func, ts, tf, is, h);
+% vin = @(t) 3.5;
+% func = @(t, iout) (vin(t) - iout*R) / L; % define func
+% [t, iout ] = ralston(func, ts, tf, is, h);
+%
+% vout = vin(t) - iout * R;
+% plot(t,vout);
+% xlabel({'Time', '(seconds)'});
+% ylabel({'V_{out}', '(volt)'});
+% title('V_{out} versus time (original function)');
+% %____________________________________________________________________
+% h = 0.0001;
+% tf = 0.03;
+% figure;
+% A = 3.5;
+% tau = 0.00015;
+%
+% vin = @(t) A * exp(-t.^2/tau);
+% func = @(t, iout) (vin(t) - iout*R) / L; % define func
+% [t, iout ] = ralston(func, ts, tf, is, h);
+%
+% vout = vin(t) - iout * R;
+% plot(t,vout);
+% xlabel({'Time', '(seconds)'});
+% ylabel({'V_{out}', '(volt)'});
+% title('V_{out} versus time (exponential square funtion)');
+% %____________________________________________________________________
+% h = 0.0001;
+% tf = 0.03;
+% figure;
+% A = 3.5;
+% tau = 0.00015;
+%
+% vin = @(t) A * exp(-t/tau);
+% func = @(t, iout) (vin(t) - iout*R) / L; % define func
+% [t, iout ] = ralston(func, ts, tf, is, h);
+%
+% vout = vin(t) - iout * R;
+% plot(t,vout);
+% xlabel({'Time', '(seconds)'});
+% ylabel({'V_{out}', '(volt)'});
+% title('V_{out} versus time (exponential function)');
-vout = vin(t) - iout * R;
-plot(t,vout);
-xlabel({'Time', '(seconds)'});
-ylabel({'V_{out}', '(volt)'});
-title('V_{out} versus time (original function)');
-%____________________________________________________________________
-h = 0.0001;
-tf = 0.03;
-figure;
-A = 3.5;
-tau = 0.000150;
-
-vin = @(t) A * exp(-t.^2/tau);
-func = @(t, iout) (vin(t) - iout*R) / L; % define func
-[t, iout ] = ralston(func, ts, tf, is, h);
-
-vout = vin(t) - iout * R;
-plot(t,vout);
-xlabel({'Time', '(seconds)'});
-ylabel({'V_{out}', '(volt)'});
-title('V_{out} versus time (exponential square funtion)');
-%____________________________________________________________________
-h = 0.0001;
-tf = 0.03;
-figure;
-A = 3.5;
-tau = 0.000150;
-
-vin = @(t) A * exp(-t/tau);
-func = @(t, iout) (vin(t) - iout*R) / L; % define func
-[t, iout ] = ralston(func, ts, tf, is, h);
-
-vout = vin(t) - iout * R;
-plot(t,vout);
-xlabel({'Time', '(seconds)'});
-ylabel({'V_{out}', '(volt)'});
-title('V_{out} versus time (exponential function)');
-
-%____________________________________________________________________
-h = 0.0001;
-tf = 0.03;
-figure;
-A = 4;
-T = 0.0015;
-
-vin = @(t) A * sin(2*pi*t/T);
-func = @(t, iout) (vin(t) - iout*R) / L; % define func
-[t, iout ] = ralston(func, ts, tf, is, h);
-
-vout = vin(t) - iout * R;
-plot(t,vout);
-xlabel({'Time', '(seconds)'});
-ylabel({'V_{out}', '(volt)'});
-title('V_{out} versus time (sine function)');
-%____________________________________________________________________
-h = 0.0001;
-tf = 0.03;
-figure;
-A = 4;
-T = 0.0015;
-
-vin = @(t) A * square(2*pi*t/T);
-func = @(t, iout) (vin(t) - iout*R) / L; % define func
-[t, iout ] = ralston(func, ts, tf, is, h);
-
-vout = vin(t) - iout * R;
-plot(t,vout);
-xlabel({'Time', '(seconds)'});
-ylabel({'V_{out}', '(volt)'});
-title('V_{out} versus time (square function)');
%____________________________________________________________________
+% h = 0.0001;
+% tf = 0.03;
+% figure;
+% A = 4;
+% T = 0.000015;
+%
+% vin = @(t) A * sin(2*pi*t/T);
+% func = @(t, iout) (vin(t) - iout*R) / L; % define func
+% [t, iout ] = ralston(func, ts, tf, is, h);
+%
+% vout = vin(t) - iout * R;
+% plot(t,vout);
+% xlabel({'Time', '(seconds)'});
+% ylabel({'V_{out}', '(volt)'});
+% title('V_{out} versus time (T=0.000015) (sine function)');
+% % ____________________________________________________________________
+% h = 0.0001;
+% tf = 0.03;
+% figure;
+% A = 4;
+% T = 0.0011;
+%
+% vin = @(t) A * square(2*pi*t/T);
+% func = @(t, iout) (vin(t) - iout*R) / L; % define func
+% [t, iout ] = ralston(func, ts, tf, is, h);
+%
+% vout = vin(t) - iout * R;
+% plot(t,vout);
+% xlabel({'Time', '(seconds)'});
+% ylabel({'V_{out}', '(volt)'});
+% title('V_{out} versus time (T=0.0011) (square function)');
+% %____________________________________________________________________
h = 0.0001;
tf = 0.03;
figure;
A = 4;
-T = 0.0015;
+T = 0.0011;
vin = @(t) A * sawtooth(2*pi*t/T);
func = @(t, iout) (vin(t) - iout*R) / L; % define func
@@ -95,7 +95,7 @@ vout = vin(t) - iout * R; plot(t,vout);
xlabel({'Time', '(seconds)'});
ylabel({'V_{out}', '(volt)'});
-title('V_{out} versus time (sawtooth function)');
+title('V_{out} versus time (T=0.0011)(sawtooth function)');
diff --git a/Part 1/ralston_sinewave(T=0.0004).fig b/Part 1/ralston_sinewave(T=0.0004).fig Binary files differnew file mode 100644 index 0000000..1e57840 --- /dev/null +++ b/Part 1/ralston_sinewave(T=0.0004).fig |