您可以从中的数据创建一个矩阵
newmat
(使用功能
sortrows
unique
和
accumarray
image
:
newmat = sortrows(newmat, [1 2]); % Sort the first two columns in ascending order
[x, ~, newmat(:, 1)] = unique(newmat(:, 1)); % Make numeric indices for column 1
[y, ~, newmat(:, 2)] = unique(newmat(:, 2)); % Make numeric indices for column 2
M = accumarray(newmat(:, 1:2), newmat(:, 3)).'; % Build the matrix
imagesc(x, y, M);
[X, Y] = meshgrid(0:0.1:2, 3:0.1:5);
Z = peaks(21);
newmat = [X(:) Y(:) Z(:)];