Plot 2D mesh data by coloured temperature

Hi all, I have imported mesh solution data from FLUENT into Matlab, and would like to plot a graph with Y and Z distance on the axes, and with each point coloured as per the temperature associated with each mesh point (e.g. red for hottest points, blue for coldest etc). This allows me to accurately display and explain my findings at a fluid outlet.
I've seen this kind of plot before but I have no idea what it's called. Can anyone help?
Thanks, Alex

 채택된 답변

Walter Roberson
Walter Roberson 2015년 12월 4일

0 개 추천

mesh(Y, Z, Temperature)
colormap(hot)
See however http://blogs.mathworks.com/steve/2014/10/20/a-new-colormap-for-matlab-part-2-troubles-with-rainbows/ for reasons why you might prefer the new parula colormap rather than hot

댓글 수: 5

Alex
Alex 2015년 12월 4일
Hi Walter, thanks for the reply.
I get an error informing me that my Z must be a matrix, not a scalar or vector. My Z data is a 193x1 table of numbers, which I thought constituted a matrix, but I'm not sure if I'm interpreting this incorrectly. My Y data follows the same format and appears to not be an issue (as Matlab did not flag this up).
Sorry if this is a basic error, I don't have a lot of experience in Matlab.
Mike Garrity
Mike Garrity 2015년 12월 4일
The 'Z' in that error message is referring to the 3rd argument (which is called Z in the help), not the variable Z which you've passed in as the 2nd argument.
So it means that the variable Temperature is not a 2D array. It's looking for a 1st arg which is has M entries, a 2nd arg which has N entries, and a 3rd arg which is a MxN array of values. Could you tell us the sizes of your arrays?
Also, a lot of the issues that Steve was addressing with his post about the problems with rainbow colormaps don't apply to the colormap 'hot'. It's actually a pretty good choice here.
Alex
Alex 2015년 12월 4일
Ah okay, that make sense. My arrays are all 198x1 (double?). Each row in each array together forms one result (so one result has a Y, Z and temperature value). Do you think that this maybe is the wrong way to do it?
I may well have incorrectly imported the data. I imported the data from a CSV file, accepting default settings for import.
Yeah, the regular color map is fine I think.
Thanks for the response!
Mike Garrity
Mike Garrity 2015년 12월 4일
Ah, mesh requires the data to be gridded. We were discussing some of the options over on this thread. You should also look at the doc for the griddata function.
Alex
Alex 2015년 12월 4일
편집: Alex 2015년 12월 4일
Thanks Mike, I'll look into that. Appreciate it!
Edit: I have achieved the desired results. I also looked at this, which clarified how to use the scatter command to its fullest.

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

추가 답변 (0개)

카테고리

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

질문:

2015년 12월 4일

편집:

2015년 12월 4일

Community Treasure Hunt

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

Start Hunting!

Translated by