How do I specify a specific time in my plot?
16 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Alex Johnson
el 18 de Jul. de 2017
Comentada: Alex Johnson
el 20 de Jul. de 2017
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')
2 comentarios
Alan Weiss
el 19 de Jul. de 2017
I'm sorry, but I do not understand what you are asking. Can you please describe exactly what you are trying to do, and what kind of information you want?
Also, I added a bit more info to a previous question of yours that might help with your current plotting routine.
Alan Weiss
MATLAB mathematical toolbox documentation
Respuesta aceptada
Alan Weiss
el 20 de Jul. de 2017
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
3 comentarios
Alan Weiss
el 20 de Jul. de 2017
Again, DON'T use line as a variable.
You just need some basic MATLAB plotting.
tt = linspace(0,1);
x = point1(1) + tt*(point1(2) - point1(1));
y = point2(1) + tt*(point2(2) - point2(1));
F = pdeInterpolant(p,t,u);
uout = evaluate(F,x,y);
figure;
s = norm(point2 - point1);
plot(tt*s,uout(:,Moment))
xlabel('Distance')
ylabel('Temperature')
title('Temperattime Along Arbitrary Line')
Alan Weiss
MATLAB mathematical toolbox documentation
Más respuestas (0)
Ver también
Categorías
Más información sobre General PDEs en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!