i want the result in the form by taking p=[1 -1 1j -1j] as initial vector resulting matrix should have p=[1 -1 1j -1j; 1 1 -1j -1j ; -1 1 1j -1j ... ] this is the sample resulting matrix .
i want the result in the form by taking p=[1 -1 1j -1j] as initial vector resulting matrix should have p=[1 -1 1j -1j; 1 1 -1j -1j ; -1 1 1j -1j ... ] this is the sample resulting matrix .
That was whatmy answer (the first one posted) gave you, so I'm not sure why you haven't considered it yet. However, there are 256 combinations that can be built as you describe, so the result will form a 256x4 matrix. It is not clear why you are expecting a result that is 256x4x2.
When I run your code, I get a 512x4 matrix, not a 256x4x2 matrix.
>> whos B
Name SizeBytesClassAttributes
B 512x432768doublecomplex
Are you just trying to get a result in which B(:,:,1) contains all 256 combinations and B(:,:,1)=B(:,:,2)? If so, I don't know why you are duplicating the data, but just take my initial proposal and modify it as follows
You can also select a web site from the following list:
How to Get Best Site Performance
Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.
2 Comments
Direct link to this comment
https://in.mathworks.com/matlabcentral/answers/381316-to-convert-a-row-into-3d-matrix-having-all-combinations#comment_532828
Direct link to this comment
https://in.mathworks.com/matlabcentral/answers/381316-to-convert-a-row-into-3d-matrix-having-all-combinations#comment_532828
Direct link to this comment
https://in.mathworks.com/matlabcentral/answers/381316-to-convert-a-row-into-3d-matrix-having-all-combinations#comment_532835
Direct link to this comment
https://in.mathworks.com/matlabcentral/answers/381316-to-convert-a-row-into-3d-matrix-having-all-combinations#comment_532835
Sign in to comment.