MATLAB: How to specify a specific time in the plot

arbitrary lineheat transfermodelpdepdemodelpdetoolboxplotplot against timeplot along lineplot at specific timesecondsspecific timetimetime domaintime limit

Using the pde toolbox and exported data (p, t, e, and u), I was able to generate a code that produces a plot along an arbitrary line drawn on my model. In this code, I specify two points (The beginning and end points of the line segment), then it plots the line versus the temperature at that point along the line. This code produces a plot of the correct information, but displays a line for every time in the pde model. For example, in my heat transfer model the system was heated for two hours (7200 seconds), the plot produced 7200 lines, one for each second in the model. I need to be able to specify a time in the heating, and plot the line against the temperature at that specific second in time. This is the plot I get with this code and all 7200 lines:
. Here is my code for what I have so far:
point1 = [0, 0]; %Enter XY coordinates of point 1
point2 = [.1, .2]; %Enter XY coordinates of point 2
F = pdeInterpolant(p,t,u);
x = linspace(point1(1), point2(1));
y = linspace(point1(2), point2(2));
uout = evaluate(F,x,y);
line = sqrt(((x-point1(1))).^2 + ((y-point1(2))).^2);
plot(line, uout)
xlabel('Distance')
ylabel('Temperature')
title('Temperattime = second(7200ure Along Arbitrary Line')

Best Answer

Just one quick thought before I answer: don't use line as a variable name, as it is the name of a built-in function.
It seems that you have a parametrized line along which you are taking a slice:
t = linspace(0.1,0.2);
x = zeros(size(t));
y = t;
uout = evaluate(F,x,y);
plot(t,uout(:,end)) % choose the last time
xlabel('y')
ylabel('Temperature')
title('Temperattime = second(7200ure Along Arbitrary Line')
If, instead, you want to plot the solution at time 3600, use the command
plot(t,uout(:,3600)) % choose time 3600
Alan Weiss
MATLAB mathematical toolbox documentation