I would like to create a contour plot for a heat transfer application, where the values of the matrix are nodal temperature values over the 2d domain of (x 0 to 0.5) and (y 0 to 1). Using the following values
25, 25, 25
111.5, 137.8, 245.1
146.3, 178.3, 296.4
111.5, 137.8, 245.1
25, 25, 25
Where, nodes are seperated by 0.25 (i.e the value at (0.5,0.5) is 296.4).
Please provide the generated plot to ensure the generated codes is functioning.

 채택된 답변

Star Strider
Star Strider 2021년 11월 23일

0 개 추천

Two possibilities —
M = [25, 25, 25
111.5, 137.8, 245.1
146.3, 178.3, 296.4
111.5, 137.8, 245.1
25, 25, 25];
figure
contour(M)
figure
contourf(M)
.

댓글 수: 4

David Krouse
David Krouse 2021년 11월 24일
Is there a way to plot it on the physical domain of the problem. Where, the x axis would range from 0 to 0.5 and the y axis would range from 0 to 1?
Star Strider
Star Strider 2021년 11월 24일
The contour plot data can be difficult to work with, especially (as here) specific levels are not continuous. It would likely be easier to scale the physical domain of the problem to the contour and adjust the axis tick labels.
What is the physical domain of the problem?
.
David Krouse
David Krouse 2021년 11월 24일
A 2d rectangular solid of dimension 0.5 by 1
That would be relatively straightforward.
M = [25, 25, 25
111.5, 137.8, 245.1
146.3, 178.3, 296.4
111.5, 137.8, 245.1
25, 25, 25];
xv = linspace(0, 0.5, size(M,2));
yv = linspace(0, 1.0, size(M,1));
figure
contour(xv,yv,M)
axis('equal') % Optional
figure
contourf(xv,yv,M)
axis('equal') % Optional
Since I’m not certain how the ‘xv’ and ‘yv’ vectors correspond to the ‘M’ matrix, it might be necessary to re-define them in terms of the dimeensions of ‘M’ if I guessed wrong. However, re-scaling them is straightforward.
Also, with axis('equal') there seems to be a bug in the x-axis ticks here, although it could just be a problem with the online Run feature, since it doesn’t appear when I run the same code offline on my computer (although the tick label at 0.5 still fails to plot). That can be fixed manually if necessary.
.

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

추가 답변 (0개)

카테고리

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

태그

질문:

2021년 11월 23일

댓글:

2021년 11월 24일

Community Treasure Hunt

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

Start Hunting!

Translated by