How to trim lines in plot?
Mostrar comentarios más antiguos
Hello, I'm trying to plot several lines in a circle and need to trim the part of lines which are out of this circle. So how can I do that? Thank you in advance
% plotting random lines
X1 = rand (8,8);
Y1 = rand (8,8);
figure
plot (X1,Y1)
hold on
% plotting the circle
R = 0.5;
angle = linspace(0,2*pi,180);
x= R*cos(angle);
y= R*sin(angle);
plot(x,y,'r')
axis equal
6 comentarios
Rik
el 14 de Mzo. de 2018
Can you provide an example of what you mean? And what did you try already?
Lisa Smith
el 14 de Mzo. de 2018
Walter Roberson
el 14 de Mzo. de 2018
Most of the time there will be a segment of the line in which one point is inside the circle and the other point is outside. Do you want to drop those segments, or do you want to calculate the intersection and draw just to the edge of the circle?
Will there be any line segments where both points are outside the circle but the line crosses the circle?
Lisa Smith
el 14 de Mzo. de 2018
Walter Roberson
el 15 de Mzo. de 2018
https://www.mathworks.com/matlabcentral/fileexchange/22441-curve-intersections
https://www.mathworks.com/matlabcentral/fileexchange/11837-fast-and-robust-curve-intersections
https://www.mathworks.com/matlabcentral/fileexchange/8908-curve-intersect-2
Lisa Smith
el 15 de Mzo. de 2018
Respuesta aceptada
Más respuestas (0)
Categorías
Más información sobre Line Plots en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
