How do I plot x,y, and an intensity value on an xy-plane with the intensity on a color scale?

3 Ansichten (letzte 30 Tage)
I have this code right now:
% Make an image of the points, then apply a colormap
x = x(:); % Extract x value
y = y(:); % Extract y value
v=v(:);
%find max and min values
minX = min(x,[],1);
maxX = max(x,[],1);
minY = min(y,[],1);
maxY = max(y,[],1);
%dealing with NaN
v(isnan(v)) = 0; %set all NaN to zero
minV=0;
maxV=max(v,[],1);
% Make image be 500 by 700
rows = 500;
columns = 700;
grayImage = zeros(rows, columns, 'uint8');
for k = 1 : length(x)
row = ceil((y(k) - minY) * rows / (maxY - minY));
column = ceil((x(k) - minX) * columns / (maxX - minX));
if (row == 0)
row = 1;
end
if (column == 0)
column = 1;
end
grayImage(row, column) = uint8(255 * (v(k) - minV) / (maxV - minV));
end
imshow(grayImage);
colorbar;
% Colormap is not gray scale.
% Apply some other colormap if you want
colormap(jet(256))

Antworten (1)

Walter Roberson
Walter Roberson am 25 Sep. 2017
cmap = jet(256);
imshow(grayImage, cmap);
colorbar();

Kategorien

Mehr zu Orange 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