필터 지우기
필터 지우기

How can I automatically adjust the radius of concentric coronas? code is given below

조회 수: 1 (최근 30일)
%%------------------------ Concentric Corona ----------------------------
t=0:0.002:1;%Initializing time samples
%Transfer chara of sine and cos i.e sin Vs Cos will give circle
%Here we are plotting group of sine Vscos with differnt amplitudes
%sin will gives
sin1=10*r*sin(2*pi*t);%Sine wave with amplitude=3unit
cos1=10*r*cos(2*pi*t);%Cosine wave with amplitude=3unit
sin2=20*r*sin(2*pi*t); % 2 will complete the circle
cos2=20*r*cos(2*pi*t);
sin3=30*r*sin(2*pi*t);
cos3=30*r*cos(2*pi*t);
sin4=40*r*sin(2*pi*t);
cos4=40*r*cos(2*pi*t);
sin5=50*r*sin(2*pi*t);
cos5=50*r*cos(2*pi*t);
sin6=60*r*sin(2*pi*t);%Sine wave with amplitude=3unit
cos6=60*r*cos(2*pi*t);%Cosine wave with amplitude=3unit
sin7=70*r*sin(2*pi*t); % 2 will complete the circle
cos7=70*r*cos(2*pi*t);
sin8=80*r*sin(2*pi*t);
cos8=80*r*cos(2*pi*t);
sin9=90*r*sin(2*pi*t);
cos9=90*r*cos(2*pi*t);
sin10=100*r*sin(2*pi*t);
cos10=100*r*cos(2*pi*t);
plot(sin1,cos1,sin2,cos2,sin3,cos3,sin4,cos4,sin5,cos5);%Plotting sin Vs Cos
hold on;
plot(sin6,cos6,sin7,cos7,sin8,cos8,sin9,cos9,sin10,cos10);
plot(0,0,'*','markersize',340);
%legend('r=5','r=3','r=1');
grid on;%Enable grid lines
axis equal;%Equal width of X and Y axis[/cc]
------------ Nodes Deployment -------------
Nodes Deployment for six zones of first subcorona of each corona%%%
angle1 =[0 pi/4 pi/2 3*pi/4 pi 5*pi/4 3*pi/2 7*pi/4 2*pi];
angle2 =[pi/4 pi/2 3*pi/4 pi 5*pi/4 3*pi/2 7*pi/4 2*pi];
j=1;
for cor=10:10:100
for i=1:8
t = (angle2(i) - angle1(i)) * 1/2 + angle1(i);
%points = r*Corona+(((r*Corona)-r)-r*Corona)*1/2;
r = cor+((cor-cor)-(5)*rand()); %*rand(); % r is the distance of node from the sink, (rand() will randomly deployed the node in the first radius
x = r.*cos(t);
y = r.*sin(t);
nodexaxis(j)=[x];
nodeyaxis(j)=[y];
%node_x_axis(j+1)=rand*nodexaxis;
j=j+1;
plot(x,y, 'ro', 'MarkerSize', 1.5)
hold on;
axis square;
%grid on;
xlabel('X');
ylabel('Y');
title('Sensor evenly distributed in circle with equal radius');
end
end
nodes_Axis=vertcat(nodexaxis,nodeyaxis);

채택된 답변

Thorsten
Thorsten 2016년 8월 9일
편집: Thorsten 2016년 8월 9일
You can considerable simplify the plotting of the nodes
x = 10:10:100;
% x = 0.1:0.1:1; % uncomment to choose a different spacing
y = zeros(size(x));
angle = pi/8:pi/4:2*pi-pi/8;
Rot = @(x) [cos(x) sin(x); -sin(x) cos(x)]; % rotation matrix
sr = -1/10*max(x); % scale of rand
XY = cell2mat(arrayfun(@(theta) [x'+sr*rand y']*Rot(theta), angle,...
'UniformOutput', false));
plot(XY(:,1:2:end), XY(:,2:2:end), 'ro', 'MarkerSize', 1.5)

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 MATLAB Compiler SDK에 대해 자세히 알아보기

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by