function plot_comunity(M) %n_comunity = length(unique(M)); [~,idx_com] = unique(sort(M),'last'); n_units_per_comunity = diff([0;idx_com]); idx = find(n_units_per_comunity>1); tmp = linspace(0.5,0.8,length(idx)); colors = repmat(tmp,3,1); for i=1:length(idx) comunity_idx = find(M == idx(i)); start = comunity_idx(1); finish = comunity_idx(end); x1 = start - 0.5;x2 = finish + 0.5; y1 = start - 0.5;y2 = finish + 0.5; x = [x1, x2, x2, x1, x1]; y = [y1, y1, y2, y2, y1]; hold all plot(x, y, '-','Color',colors(:,i),'LineWidth',2); end end