How to mirror a plot in x and y axis.

20 visualizaciones (últimos 30 días)
Matthew
Matthew el 8 de Abr. de 2013
Comentada: Siddharth Behal el 17 de Dic. de 2021
I want to mirror a plot in x and y axis so i forms a symmetrical shape made of four of the same randomly generated polygon.
prompt = {'Enter Number of vertices:',}
numberOfVertices = str2num(cell2mat(inputdlg(prompt, 'enter a number', 5)))
%numberOfVertices = 7; % Fixed at 7 for this demo.
coordinates = rand(numberOfVertices, 2);
coordinates(1,:) = [0, 0]; % Force first coord to 0,0
coordinates(end+1,:) = [0, 0]; % Force last coord to 0,0
plot(coordinates(:,1), coordinates(:,2));
grid on;
randomColor = rand(1,3);
patch(coordinates(:,1), coordinates(:,2), randomColor); % Can use fill() also.
set(gca, 'xdir', 'reverse');
grid on;

Respuesta aceptada

Yao Li
Yao Li el 8 de Abr. de 2013
Editada: Yao Li el 8 de Abr. de 2013
*mirror both in x axis and y axis
hold on
plot(-coordinates(:,1), -coordinates(:,2));
mirror only in x axis
hold on
plot(coordinates(:,1), -coordinates(:,2));
mirror only in y axis
hold on
plot(-coordinates(:,1), coordinates(:,2));
*
  5 comentarios
Matthew
Matthew el 8 de Abr. de 2013
Never mind i got it.
Siddharth Behal
Siddharth Behal el 17 de Dic. de 2021
How you did it?

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Elementary Polygons en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by