Creating a curved triangular heatmap .
显示 更早的评论
I had a sample of material that resembled a right-angled triangle with a curved hypothenuse, on which I drew a grid to carry out a hardness test (0.5 HV), to see how the hardness varies across the sample surface. It is attached as an Excel spreadsheet 'Raw_data'
I then exported this spreadsheet as a matrix. If it were perfectly rectangular, it would be a 10x16 matrix, however due to it spatially describing a sector of an oval, the number of columns decrease non-uniformly.
I intend to plot the hardness as a function of spatial coordinate as a heatmap. This is my code thus far:
[X,Y] = meshgrid(0:2:30,0:2:18);
Z = Rawdata;
T = delaunay(X,Y);
trisurf(T,X,Y,Z)
view (2)
shading interp
How do I modify this in order to make the edge of the heatmap vary smoothly, i.e remove the steps so that it instead describes the arc of an oval? Thanks so much!
回答(1 个)
You need not to use delaunayTriangulation. Your grid is already a structured grid and you can striaght away plot using pcolor. You can increase the grid resolution and use interp2 to get smooth variation.
[X,Y] = meshgrid(0:2:30,0:2:18);
T = readtable('https://in.mathworks.com/matlabcentral/answers/uploaded_files/900375/Raw%20data.xlsx') ;
Rawdata = table2array(T) ;
Z = Rawdata;
pcolor(X,Y,Z) ;
shading interp ;
title('Original')
x = linspace(0,30) ;
y = linspace(0,18) ;
[Xi,Yi] = meshgrid(x,y) ;
Zi = interp2(X,Y,Z,Xi,Yi) ;
pcolor(Xi,Yi,Zi) ;
shading interp
title('Interpolated')
类别
在 帮助中心 和 File Exchange 中查找有关 Data Distribution Plots 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!

