How do I specify a specific time in my plot?
조회 수: 16 (최근 30일)
이전 댓글 표시
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
Alan Weiss
2017년 7월 19일
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
채택된 답변
Alan Weiss
2017년 7월 20일
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
Alan Weiss
2017년 7월 20일
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
추가 답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 General PDEs에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!