MATLAB Answers

How to create a 2x2 matrix?

89 views (last 30 days)
Gn Gnk
Gn Gnk on 4 Dec 2019
Edited: Adam Danz on 4 Dec 2019
Hello ,
i want to create a 2x2 matrix like that :
, h is 2x500 matrix .
So , i have to create a 2x2 matrix that each cell contains 2x500 matrix
I tried to write:
M = [h(1,:) h(2,:) ; h(2,:) h(1,:)]
But that ends up with a 2x1000 matrix .
What should i do ?
*Note that h is a complex array
thank you.

  0 Comments

Sign in to comment.

Accepted Answer

Adam Danz
Adam Danz on 4 Dec 2019
Edited: Adam Danz on 4 Dec 2019
Use curly brackets instead of square brackets.
M = {h(1,:) h(2,:); h(2,:) h(1,:)};

  0 Comments

Sign in to comment.

More Answers (1)

Raj
Raj on 4 Dec 2019
h1=rand(2,500)+i*rand(2,500) % Your first matrix
h2=rand(2,500)+i*rand(2,500) % Second matrix
M=[{h1} {h2};{h2} {h1}]

  0 Comments

Sign in to comment.

Sign in to answer this question.