I solved a 1D moving boundary heat transfer problem and I want to recreate something like the graphs on the left in this image. Anyone know how I can do that?

댓글 수: 2

jonas
jonas 2018년 7월 30일
편집: jonas 2018년 7월 30일
The left graphs are not good in my opinion. They should not have smooth colorbars, falsely indicating step-wise changes in temperature.
What type of data do you have? Did you try contourf?
Hey thanks for your help!
Well it's a 1d ice cube, so I solved for the temperature at each discretization point
---------Temp ---------Temp ---------Temp ---------Temp
and so on. I tried contourf and got something that didn't make sense but I also don't use it very much so maybe I didn't know how to plot it properly?
Say at time step 1: I have 5 temperatures which I solved for in addition to the temperatures on the boundaries. I also have their positions in the x-axis. So what I did is I concatenated those vectors and did contourf on that but it didn't work :/
Z = [temps positions] contourf(Z)
I have attached what I got.

댓글을 달려면 로그인하십시오.

 채택된 답변

jonas
jonas 2018년 7월 31일
편집: jonas 2018년 7월 31일

1 개 추천

Looks like you actually have a 2D data set but want to plot in 3D, which means you have to add an arbitrary 'depth'. This will give you a color-figure that is more difficult to interpret than a normal 2D-plot. Nevertheless, I've made a small example, with result attached.
%%Create data
x=0:180;
z=-sind(x);
figure;
subplot(1,3,1)
plot(x,z)
axis tight
%%Extrude to a width of 10 and plot
subplot(1,3,2)
y=1:10;
z2=repmat(z,numel(y),1);
contourf(x,y,z2)
subplot(1,3,3)
surf(x,y,z2,'edgecolor','none')
colorbar
Note: Surf and contourf will connect the data linearly. If you want a more correct shape of the temperature distribution, then you have to either solve for more points or apply another interpolation method prior to plotting (using e.g. meshgrid & griddata).

댓글 수: 1

Thanks Jonas. I'll try this as well.
I actually did try the meshgrid method last night and because I don't entirely understand it, I ended up playing around with the inputs to that and contourf and finally was able to get the plot I wanted by making sure that the Z matrix was just a repeat of the temperature data.
I'll have to study those two functions to actually understand why that worked. I'll also try your method.
Thanks again for your help!!

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

도움말 센터File Exchange에서 Contour Plots에 대해 자세히 알아보기

질문:

2018년 7월 30일

댓글:

2018년 7월 31일

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by