How to plot points from a geometric transformation matrix?
Show older comments
In the following code I need to change the plot function code every time the number of vertices change. Is there a function which can plot any number of vertices?
clc
clear
n=input('Enter the number of vertices')
for i=1:n
x(i)=input('Enter the x coordinate');
y(i)=input('Enter the y coordinate');
end
a=[x;y;ones(1,n)]
ro=[-1 0 0;0 -1 0;0 0 1];
disp('The final Matrix is')
c=ro*a
grid on
hold on
X1=[a(1,1),a(1,2),a(1,3),a(1,4),a(1,1)];
Y1=[a(2,1),a(2,2),a(2,3),a(2,4),a(2,1)];
plot(X1,Y1,'g')
fill(X1,Y1,'g')
X2=[c(1,1),c(1,2),c(1,3),c(1,4),c(1,1)];
Y2=[c(2,1),c(2,2),c(2,3),c(2,4),c(2,1)];
plot(X2,Y2,'r')
fill(X2,Y2,'r')
hold off
Accepted Answer
More Answers (0)
Categories
Find more on Labels and Annotations in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!