我有这些数据,矩阵边缘的值和矩阵内均匀间隔的其他值。我想从原始值预测零位置的值,并制作新数据的热图。通过建议,我使用scatInterpolant,ndgrid和interpolant,因为数据是interp2(matlab函数)不能用于插值零元素。现在,这种方法不能给我一个平滑的数字,我想知道是否有人可以提供一些帮助。我已将我的代码,数据和代码中的数字附加到此帖子。谢谢。
[knownrows, knowncolumns, knownvalues] = find(DataGrid); %get location and value of all non-zero points
interpolant = scatteredInterpolant(knownrows, knowncolumns, knownvalues,'linear'); %create interpolant from known values
[queryrows, querycolumns] = ndgrid(1:1:size(DataGrid, 1), 1:1:size(DataGrid, 2)); %create grid of query points
interpolatedj = interpolant(queryrows, querycolumns);
热图(interpolatedj)
答案 0 :(得分:0)
要绘制平滑矩阵,您可以使用pcolor
并将着色参数设置为interp
pcolor(M); %where M is your 2D matrix
shading interp %set the shading to interp
答案 1 :(得分:0)
尝试
image(M)
或imagesc(M)
其中M是矩阵。 pcolor(M)
也有效。如果您的矩阵很大,那么您需要删除边缘,否则图形看起来像空白图像。