I have the temperature values for the variable Y for 8 node points in 1D . Now when I try to plot I get the temperature gradient as individual boxes as shown below. I dont want this. The code for achieving this result is shown below
heatmap_1d.jpg
Y =
1.0e+03 *
4.1962
3.5087
2.8783
2.3026
1.7775
1.2967
0.8516
0.4318
figure(1)
imagesc(Y)
axis equal
axis off
colorbar;
Annotation 2019-07-13 011733.png
I need to get an smooth image like the one shown in second figure where the transition is smooth between the temperature gradients.
Any help will be appreciated !

댓글 수: 1

infinity
infinity 2019년 7월 13일
Hello,
The problem is that your data is very coarse. You got the temperature only at 8 points. One of the tasks you shoud be done first is to inpterpolate your data to the finer mesh.
When you obtain smoother data, you can plot smoother figure.

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

 채택된 답변

Sai Bhargav Avula
Sai Bhargav Avula 2019년 7월 16일
편집: Sai Bhargav Avula 2019년 7월 16일

1 개 추천

Hi Sreenivas,
You are trying to generate the heatmap using only 8 points. Try to interpolate the data using the interp1 function.
For our case:
Y = 1000*[4.1962 3.5087 2.8783 2.3026 1.7775 1.2967 0.8516 0.4318];
X = linspace(1,10,100);
Y = interp1(Y,X);
imagesc(Y);
axis equal
axis off;
colorbar;
Here X is an equally spaced array of 100 elements and is the second argument for the interp1 function. The interp1 function considers the Y as a function and queries for the Y values at each value of X. This results in a Y array with 100 elements, which is ufficient to generate a smooth 1D heat map.

추가 답변 (0개)

카테고리

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

Community Treasure Hunt

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

Start Hunting!

Translated by