How can I plot in the same coordinate system this two images that the execution of the two codes below gives?
1 visualización (últimos 30 días)
Mostrar comentarios más antiguos
function h = circle(x,y,r) % r is 30 hold on th = 0:pi/50:2*pi; xunit = r * cos(th) + x; yunit = r * sin(th) + y; h = plot(xunit, yunit); hold off
AND
R = 15 ; Delta = 3; xVertex = R * cos((0:6)*pi/3 ); yVertex = R * sin((0:6)*pi/3 ); xVertex = [xVertex , xVertex(1 )]; yVertex = [yVertex , yVertex(1 )]; requiredPoints = 20 ; plot(xVertex, yVertex, 'b+-', 'LineWidth', 3 ); grid on ; numPointsIn = 1 ; while numPointsIn < requiredPoints testx = 2 * R * rand(1) - R ; testy = 2 * R * rand(1) - R ; if inpolygon(testx, testy, xVertex, yVertex ) x(numPointsIn) = testx ; y(numPointsIn) = testy ;
D = x - R
if D <= Delta
Sc = x
end
numPointsIn = numPointsIn + 1 ;
end
end
hold on ;
plot(x,y,'r+', 'MarkerSize', 10, 'LineWidth', 2 );
yAngle = atan2(y, x) + pi
x
0 comentarios
Respuestas (1)
RobF
el 23 de En. de 2018
Editada: RobF
el 23 de En. de 2018
You might want to delete/comment out the hold off statement and try the following:
% circle(1, 2, 3)
x=1;
y=2;
r=3;
% function h = circle(x,y,r)
% r is 30
hold on
th = 0:pi/50:2*pi;
xunit = r * cos(th) + x;
yunit = r * sin(th) + y;
h = plot(xunit, yunit);
% hold off
R = 15 ;
Delta = 3;
xVertex = R * cos((0:6)*pi/3 );
yVertex = R * sin((0:6)*pi/3 );
xVertex = [xVertex , xVertex(1 )];
yVertex = [yVertex , yVertex(1 )];
requiredPoints = 20;
plot(xVertex, yVertex, 'b+-', 'LineWidth', 3 );
grid on;
numPointsIn = 1;
while numPointsIn < requiredPoints
testx = 2 * R * rand(1) - R ;
testy = 2 * R * rand(1) - R ;
if inpolygon(testx, testy, xVertex, yVertex )
x(numPointsIn) = testx ;
y(numPointsIn) = testy ;
D = x - R
if D <= Delta
Sc = x
end
end
numPointsIn = numPointsIn + 1 ;
end
hold on;
plot(x,y,'r+', 'MarkerSize', 10, 'LineWidth', 2 );
yAngle = atan2(y, x) + pi;
% end
Ver también
Categorías
Más información sobre Tracking and Sensor Fusion en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!