MATLAB: “plus/minus” sign operator

plus/minus

Hi
I have a row matrix which is like n=[x,y,z] I need to consider plus and minus signs at the same time and get a permutations of them. In conclusion I need that solutions
n=[x,y,z]
n=[-x,y,z]
n=[x,-y,z]
n=[x,y,-z]
n=[-x,-y,z]
n=[-x,y,-z]
n=[x,-y,-z]
n=[-x,-y,-z]

Best Answer

It depends what you want to do with it.
M = [1 1 1; 1 1 -1; 1 -1 1; 1 -1 -1; -1 1 1; -1 1 -1; -1 -1 1; -1 -1 -1];
Out = (M * Row')' ;
Each row of Out is what you want.
You might want to programatically generate M if you have more columns on your row.