How to create a smooth heatmap for 1D ?

31 Ansichten (letzte 30 Tage)
Sreenivas Ramakrishnan
Sreenivas Ramakrishnan am 12 Jul. 2019
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 Kommentar
infinity
infinity am 13 Jul. 2019
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.

Melden Sie sich an, um zu kommentieren.

Akzeptierte Antwort

Sai Bhargav Avula
Sai Bhargav Avula am 16 Jul. 2019
Bearbeitet: Sai Bhargav Avula am 16 Jul. 2019
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.

Weitere Antworten (0)

Kategorien

Mehr zu Colormaps finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by