how to get plus and minus sign element of matrix at the same time?

2 visualizaciones (últimos 30 días)
frwmetric
frwmetric el 16 de Mayo de 2013
I have a matrix like n=[x,y,z] I need to consider plus and minus sign of x,y and z "at the same time" because I need unique permutation of mix signs as well s.t. [-x,y,z],[x,-y,-z],etc.

Respuestas (1)

Sean de Wolski
Sean de Wolski el 16 de Mayo de 2013
[xx yy zz] = meshgrid(-1:1);
[xx(:) yy(:) zz(:)]
?
  2 comentarios
frwmetric
frwmetric el 16 de Mayo de 2013
Editada: Azzi Abdelmalek el 19 de Mayo de 2013
Thank you for answer but... result for your codes
[-1 -1 -1;
-1 0 -1;
-1 1 -1;
0 -1 -1;
0 0 -1;
0 1 -1;
1 -1 -1;
1 0 -1;
1 1 -1;
-1 -1 0;
-1 0 0;
-1 1 0;
0 -1 0;
0 0 0;
0 1 0;
1 -1 0;
1 0 0;
1 1 0;
-1 -1 1;
-1 0 1;
-1 1 1;
0 -1 1;
0 0 1;
0 1 1;
1 -1 1;
1 0 1;
1 1 1]
I thought that I can multiply with its each rows but here zeros are problem... Maybe you meant completely different thing... I am sorry, I am very new user...
Sean de Wolski
Sean de Wolski el 16 de Mayo de 2013
That was just to demonstrate, if you don't want zeros:
meshgrid([-2 -1 1 2]);
If you have x y and z, this is equivalent to:
meshgrid([-x -y -z x y z]);

Iniciar sesión para comentar.

Categorías

Más información sobre Startup and Shutdown en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by