how to get plus and minus sign element of matrix at the same time?
2 views (last 30 days)
Show older comments
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.
0 Comments
Answers (1)
Sean de Wolski
on 16 May 2013
[xx yy zz] = meshgrid(-1:1);
[xx(:) yy(:) zz(:)]
?
2 Comments
Sean de Wolski
on 16 May 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]);
See Also
Categories
Find more on Startup and Shutdown 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!