diff options
author | Yann Herklotz <ymherklotz@gmail.com> | 2017-03-12 14:53:10 +0000 |
---|---|---|
committer | Yann Herklotz <ymherklotz@gmail.com> | 2017-03-12 14:53:10 +0000 |
commit | 5f9760ac7f47dcef22a8bdaaa45cdbbb13170c53 (patch) | |
tree | 771e1166a7bea9e2671aa50c6ff8cc2600459193 | |
parent | 22bb6a946266a0f62d85a442194beaeb6797175f (diff) | |
download | NumericalAnalysis-5f9760ac7f47dcef22a8bdaaa45cdbbb13170c53.tar.gz NumericalAnalysis-5f9760ac7f47dcef22a8bdaaa45cdbbb13170c53.zip |
improved steps
-rw-r--r-- | Part 3/scripts/finite_script.m | 14 | ||||
-rw-r--r-- | Part 3/scripts/get_function.m | 6 |
2 files changed, 13 insertions, 7 deletions
diff --git a/Part 3/scripts/finite_script.m b/Part 3/scripts/finite_script.m index 4812535..a6bdb5d 100644 --- a/Part 3/scripts/finite_script.m +++ b/Part 3/scripts/finite_script.m @@ -3,6 +3,8 @@ clear; +steps = 100; + % Set the number of samples to take N = 150; @@ -20,11 +22,11 @@ h = 1/N; k = h^2 * v; % Set Initial condition -res(:, 1) = get_function(N, h, 1)'; +res(:, 1) = get_function(N, h, 3)'; % Set boundary conditions -res(1, :) = ones(1, m+1); -res(N+1, :) = ones(1, m+1); +res(1, :) = zeros(1, m+1); +res(N+1, :) = zeros(1, m+1); % Calculate M+1 and plot it continuously for c = 1:m @@ -35,10 +37,10 @@ end % Plot 2D figure; -Z = zeros(N+1, m/50+1); +Z = zeros(N+1, m/steps+1); count = 1; for i = 1:m+1 - if rem(i, 50) == 1 + if rem(i, steps) == 1 plot(0:h:1, res(:, i)); Z(:, count) = res(:, i); hold on; @@ -54,7 +56,7 @@ legend('m = 0', 'm = 100', 'm = 200', 'm = ...', 'm = 5000'); % Plot 3D figure; -x = (0:m/50) / (m/50); +x = (0:m/steps) / (m/steps); y = (0:N) / N; [X,Y] = meshgrid(x, y); surf(X, Y, Z); diff --git a/Part 3/scripts/get_function.m b/Part 3/scripts/get_function.m index b34ee30..7390900 100644 --- a/Part 3/scripts/get_function.m +++ b/Part 3/scripts/get_function.m @@ -14,8 +14,12 @@ if f == 1 end elseif f == 2 y = sin(2*pi*(0:h:1)); -else +elseif f == 3 y = abs(sin(2*pi*(0:h:1))); +elseif f == 4 + %add func +elseif f == 5 + %add end end |