diff options
author | Vasil Zlatanov <v@skozl.com> | 2017-03-06 19:04:39 +0000 |
---|---|---|
committer | Vasil Zlatanov <v@skozl.com> | 2017-03-06 19:04:39 +0000 |
commit | ead17653f4b783b3cd585616efdd387046517cdd (patch) | |
tree | 6881cbb5ada86d9d13e177128adfd64e41395297 /coursework17 | |
parent | b62bc27fcd6450ac4a1b056c833a5f81cb09b472 (diff) | |
download | e2-matlab-ead17653f4b783b3cd585616efdd387046517cdd.tar.gz e2-matlab-ead17653f4b783b3cd585616efdd387046517cdd.tar.bz2 e2-matlab-ead17653f4b783b3cd585616efdd387046517cdd.zip |
change condition 4
Diffstat (limited to 'coursework17')
-rw-r--r-- | coursework17/ex4.m | 36 |
1 files changed, 21 insertions, 15 deletions
diff --git a/coursework17/ex4.m b/coursework17/ex4.m index 7e2175a..b480258 100644 --- a/coursework17/ex4.m +++ b/coursework17/ex4.m @@ -5,14 +5,17 @@ clear -dx = input('Input position step (for example 0.01): '); % play about with this to get resolution +dx = 0.002 +% dx = input('Input position step (for example 0.01): '); % play about with this to get resolution % Calulate maximum dt to maintain stability, based on the tailor expansion. dt = dx^2/2; -tfin = input('Input the time you wawnt to end the simulation (for example 0.1): '); +tfin = 0.1 +% tfin = input('Input the time you wawnt to end the simulation (for example 0.1): '); -lines = input('How many lines across the time range would you like to plot (for example 10): '); +lines = 10 +% lines = input('How many lines across the time range would you like to plot (for example 10): '); % Create x and t for plotting in the array x = 0:dx:1; @@ -34,24 +37,27 @@ u(1,length(x)) = 0; % % Initial condition 2 % for i = 1:length(x) -% u(1,i) = abs(sin(2*pi*x(i))); -% % u(1,i) = sin(2*pi*x(i)); +% % u(1,i) = abs(sin(2*pi*x(i))); +% u(1,i) = sin(2*pi*x(i)); % end % % Initial Condition 3 % for i = 0.25/dx:0.75/dx % u(1,i) = 1; % end +% - -% Initial Condition 4 -for i = 1:0.5/dx - u(1,i) = -1; -end -for i = 0.5/dx+1:length(x) - u(1,i) = 1; -end - + % Initial Condition 4 + for i = 1:0.25/dx + u(1,i) = -1; + end + for i = 0.25/dx+1:0.75/dx + u(1,i) = -1+(i*dx-0.25)*4; + end + for i = 0.75/dx+1:length(x) + u(1,i) = 1; + end + @@ -76,6 +82,6 @@ for i = 1:round(length(t)/lines):length(t) plot(x,u(i,:),'.'); legendInfo{j} = ['t = ' num2str(round(i*dt, 3))]; end -legend(legendInfo); +legend(legendInfo,'Location', 'southeast'); xlabel('Displacement'); ylabel('Temperature'); |