From b62bc27fcd6450ac4a1b056c833a5f81cb09b472 Mon Sep 17 00:00:00 2001 From: Vasil Zlatanov Date: Mon, 6 Mar 2017 18:37:51 +0000 Subject: implement legend and labels --- coursework17/ex4.m | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/coursework17/ex4.m b/coursework17/ex4.m index 6f44271..7e2175a 100644 --- a/coursework17/ex4.m +++ b/coursework17/ex4.m @@ -3,6 +3,8 @@ % h = dx % k = dt +clear + 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. @@ -12,8 +14,6 @@ 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): '); -% v = dx/(dt^2); %redundant - % Create x and t for plotting in the array x = 0:dx:1; t = 1:dt:tfin+1; @@ -70,6 +70,12 @@ end figure; hold on; +j = 0 for i = 1:round(length(t)/lines):length(t) + j = j+1; plot(x,u(i,:),'.'); + legendInfo{j} = ['t = ' num2str(round(i*dt, 3))]; end +legend(legendInfo); +xlabel('Displacement'); +ylabel('Temperature'); -- cgit v1.2.3-54-g00ecf