to convert a row into 3d matrix having all combinations

1 次查看(过去 30 天)
i have a piece of code p=[1 -1 1j -1j] i want to convert this 1x4 matrix into 256X4x2 matrix. how to fix this bug .

回答(2 个)

Matt J
Matt J 2018-2-7
编辑:Matt J 2018-2-7
You've left us to do a lot of guessing as to what you want, but here's my guess,
[c{1:4}]=ndgrid(p);
result=reshape(cell2mat(c),256,4);

Ahmed Mahfouz
Ahmed Mahfouz 2018-2-7
i don't know what you exactly mean but i assumed the entries to the 3d matrix are the same as in the given vector, you can try the following code:
p=[1 -1 1j -1j];
for n=1:256
Matrix(n,:)=p;
end
Matrix(:,:,2)=Matrix(:,:,1);
  10 个评论
ABDUL
ABDUL 2018-2-8
if i want to retain the same size of 512x4 what do i have to modify.

请先登录,再进行评论。

类别

Help CenterFile Exchange 中查找有关 Logical 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by