How to remove lines' segments located outside square?
Afficher commentaires plus anciens
Hi all, The following code is used to draw multiple lines and square of area (1x1);
%%PLOT lines
deg = 0 : 5 : 90;
r=2;
x_ax = r*[zeros(size(deg(:))) cosd(deg(:))];
y_ax = r*[zeros(size(deg(:))) sind(deg(:))];
plot(x_ax', y_ax', 'LineWidth',1)
hold on
%%Plot square
x1=0;
x2=1;
y1=0;
y2=1;
x = [x1, x2, x2, x1, x1];
y = [y1, y1, y2, y2, y1];
plot(x, y, 'b-', 'LineWidth', 2.5);
grid on
grid minor
axis equal
xlim([-0.2,1.2])
ylim([-0.2,1.2])
The output would be as the following image;

My question is;
How to remove the multiple lines' segments that are located outside the (1x1) square?
So, the output should be like that;

Any suggestions for code to do that?
1 commentaire
Image Analyst
le 1 Fév 2020
Original question by Erman, in case he also deletes this one:
How to remove the multiple lines' segments that are located outside the (1x1) square?
Hi all, The following code is used to draw multiple lines and square of area (1x1);
%%PLOT lines
deg = 0 : 5 : 90;
r=2;
x_ax = r*[zeros(size(deg(:))) cosd(deg(:))];
y_ax = r*[zeros(size(deg(:))) sind(deg(:))];
plot(x_ax', y_ax', 'LineWidth',1)
hold on
%%Plot square
x1=0;
x2=1;
y1=0;
y2=1;
x = [x1, x2, x2, x1, x1];
y = [y1, y1, y2, y2, y1];
plot(x, y, 'b-', 'LineWidth', 2.5);
grid on
grid minor
axis equal
xlim([-0.2,1.2])
ylim([-0.2,1.2])
The output would be as the following image;

My question is;
How to remove the multiple lines' segments that are located outside the (1x1) square?
So, the output should be like that;

Any suggestions for code to do that?
Réponse acceptée
Plus de réponses (0)
Catégories
En savoir plus sur Graphics Object Properties dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
