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?
clcclearn=input('Enter the number of vertices')for i=1:n x(i)=input('Enter the x coordinate'); y(i)=input('Enter the y coordinate');enda=[x;y;ones(1,n)]ro=[-1 0 0;0 -1 0;0 0 1];disp('The final Matrix is')c=ro*agrid onhold onX1=[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
Best Answer