From: Asim Ali Shah on 3 Aug 2010 07:04 clear; noOfNodes = 10; rand('state', 0); figure(1); clf; hold on; L = 1000; R = 200; % maximum range; netXloc = rand(1,noOfNodes)*L; netYloc = rand(1,noOfNodes)*L; for i = 1:noOfNodes plot(netXloc(i), netYloc(i), '.'); text(netXloc(i), netYloc(i), num2str(i)); for j = 1:noOfNodes distance = sqrt((netXloc(i) - netXloc(j))^2 + (netYloc(i) - netYloc(j))^2); if distance <= R matrix(i, j) = 1; % there is a link; line([netXloc(i) netXloc(j)], [netYloc(i) netYloc(j)], 'LineStyle', ':'); else matrix(i, j) = inf; end; end; end;
|
Pages: 1 Prev: Comparing variables contained in MAT files Next: GUI and fungtions compile to application |