clc;close all; % Close all figures (except those of imtool.)
clear; % Erase all existing variables. Or clearvars if you want.
workspace; % Make sure the workspace panel is showing.
format long g;format compact;fontSize = 25;figure;imshow('pc3.png');hold onhold on%legend('Relay', 'Sink', 'Sensor');
%
x1 = [105,107,58,58,75,146,118,18,48,55,108,80,80];y1 = [190,280,190,280,145,153,103,153,103,65,65,50,10];hold onA=100;B=140;plot(A,B, 'mo-', 'MarkerSize', 10,'LineWidth', 2);hold on% Make 75 points in set #2
Xmin = 60;Xmax = 99;x2 = Xmin+rand(1,50)*(Xmax-Xmin);Ymin = 10;Ymax= 260;y2 = Ymin+rand(1,50)*(Ymax-Ymin);plot(x2, y2, 'b*');%numPoints2 = 50;
%x2 = 167*rand(numPoints2, 1);
%y2 = 302*rand(numPoints2, 1);
% Plot set 1 in red
plot(x1, y1, 'r.', 'MarkerSize', 13);% Plot set 2 in blue
hold on;plot(x2, y2, 'b*', 'MarkerSize', 5);grid on;for i=1:13 for j=1:50 %Find distances between every point in set 1 to every point in set #2.
distances(i,j) = pdist2([x1(i),y1(i)], [x2(j), y2(j)], 'euclidean'); end minDistance(i) = min(distances(i,:));end% Find min distance
disp (distances);dist1 = sqrt((x2-A).^2+(y2-B).^2)%disp (dist1);
dist2 =sqrt((x1-A).^2+(y1-B).^2)disp (minDistance);a=1:40;for i = 1:10 pop(i,:) = a(randperm(numel(a),10))endfor i = 1:10 opo_pop(i,:) = 40-pop(i,:)end %Est(13,5)=zeros();
%for i=1:13
% b=1;
%for k=1:50
%for j=10*k-9:10*k
%if mod(k,10)==0
%b=b+1;
%end
s=250; Et=16.7; Eamp=1.97; N=10;data_agg=1;Er = 36.1;d0=30;c=10; for k = 1:13 for j = 1:10 for i = 1:10 Ets(k,j,i)=s*(Et+Eamp*(distances(k,pop(j,i)).^2)); %Es(i,b)=Est(i,b)+Et(i,k);
end end enddisp (Ets);for k = 1:13 for j = 1:10 for i = 1:10 OEts(k,j,i)=s*(Et+Eamp*(distances(k,opo_pop(j,i)).^2)); %Es(i,b)=Est(i,b)+Et(i,k); end end enddisp (OEts);
%not able to get the output
Best Answer