function [mmin, mmax]=plot_ntwk(node_positions, user_positions, plotpitch, min_node_spacing) %%%%%%%%%%%%%%%%BUGS % % with a circular node layout, I get negative plot locations with more than ~17 nodes % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Nodes=length(node_positions); if(size(user_positions,2) == 1); Users=0 else Users=size(user_positions,1); end span=floor(.025*plotpitch); span_i=floor(.5*span); xnmin=min(node_positions(:,1)); xnmax=max(node_positions(:,1)); ynmin=min(node_positions(:,2)); ynmax=max(node_positions(:,2)); if(Users >0) xumin=min(user_positions(:,1)); xumax=max(user_positions(:,1)); yumin=min(user_positions(:,2)); yumax=max(user_positions(:,2)); else xumin=xnmin; xumax=xnmax; yumin=ynmin; yumax=ynmax; end xmin=min(xnmin, xumin); ymin=min(ynmin, yumin); xmax=max(xnmax, xumax); ymax=max(ynmax, yumax); xymin=min(xmin,ymin)-30*min_node_spacing*span/plotpitch; xymax=max(xmax, ymax)+30*min_node_spacing*span/plotpitch; x=(xymin:(xymax-xymin)/(plotpitch-1):xymax); y=(xymin:(xymax-xymin)/(plotpitch-1):xymax); Z=-1000*ones(plotpitch,plotpitch); C=-10*ones(plotpitch,plotpitch); for i=1:Nodes for k=-span:span mlimit=floor(sqrt(span^2-k^2)); %approximate a circle. looks cleaner than a square for m=-mlimit:mlimit npx=floor((plotpitch-1)*(node_positions(i,1)-xymin)/(xymax-xymin)+.5); npy=floor((plotpitch-1)*(node_positions(i,2)-xymin)/(xymax-xymin)+.5); if(k^2 + m^2 < .7*span^2) C(k+1+npx,m+1+npy)=-3; else C(k+1+npx,m+1+npy)=-20; end Z(k+1+npx,m+1+npy)=0; end end end if(Users >0) for i=1:Users for k=-span_i:span_i for m=-span_i:span_i ipx=floor((plotpitch-1)*(user_positions(i,1)-xymin)/(xymax-xymin)+.5); ipy=floor((plotpitch-1)*(user_positions(i,2)-xymin)/(xymax-xymin)+.5); C(1+m+ipx,1+k+ipy)=5; Z(1+m+ipx,1+k+ipy)=-5; end end end end gcf=figure(30); surf(x,y,Z',C'); shading interp colormap(jet) grid on % symmetrical axis around (0,0) mmax=1.2*max(max(abs(xmin),abs(ymin)),max(abs(xmax),abs(ymax))); mmin=-mmax; axis([mmin mmax mmin mmax -5 5]); axis square axis xy caxis([-10 0]) view(2) set(gcf,'NumberTitle','off','Name','Node Plot') xlabel('X'); ylabel('Y');