image - Sparse matrix plot matlab -
i have 5000 *5000 sparse matrix 4 different values. want visualise nonzero elements 4 different colors such can recognise ratio of values , relationships between them,i use imagesc can not recognise among different values, values smaller ratio.i think if use symboles each value , works don't know how in matlab. suggestion? result of dan code in figure below.
you reform matrix set of [x, y, f] coordinates (re-using answer resampling matrix , restoring in 1 single matrix):
assuming matrix m
[x, y] = meshgrid(1:size(m,1), 1:size(m,2)); mf = m(:); %used again later, hence stored v = [x(:), y(:), mf];
get rid of 0 elements
v(mf == 0, :) = [];
at point, if have access statistics toolbox can go gscatter(v(:,1), v(:,2), v(:,3))
correct plot otherwise continue following if don't have toolbox:
find list of unique values in m
vu = unique(v(:,3));
for each such value, plot points xy scatter plot, note hold makes sure colour changes each time new plot added i.e. each new iteration of loop
hold all; g = 1:length(vu) vg = v(v(:,3)==vu(g),:) plot(vg(:,1), vg(:,2), '*'); a{g}=num2str(vu(g)); end legend(a);
example m
:
m = zeros(1000); m(200,30) = 7; m(100, 900) = 10; m(150, 901) = 13; m(600, 600) = 13;
result:
Comments
Post a Comment