MATLAB Answers

Reshape the Matrix to complex number ?

조회 수: 5(최근 30일)
abdullah qasim
abdullah qasim 2019년 1월 9일
편집: abdullah qasim 2019년 1월 9일
I have Matrix-like the following
%X is the complex number % complex number(a+ib) where (a) is real and (ib)is imag number
% I reshap the complex to matrix
X %(64 1) size of matrix = N
real(X); % (64 1)
imag(X); % (64 1)
Xd=[real(X);imag(X)]; %(128 1) = 2N
I want to reshap the matrix to complex as
return (X) at size (64 1)
thank u
  댓글 수: 2
Steven Lord
Steven Lord 2019년 1월 9일
What you've described sounds like you just want X back.
If X were the following matrix, can you show exactly what you'd expect / want the result of this "reshaping" to be? Seeing the results for a specific matrix might help us understand what you're trying to do.
X = [1+2i; 3+4i; 5+6i; 7+8i; 9+10i]

댓글을 달려면 로그인하십시오.

채택된 답변

Stephen 2019년 1월 9일
편집: Stephen 2019년 1월 9일
Some methods to get the original (complex) matrix back:
Y = reshape(Xd,[],2)*[1;i]
Method two: indexing and complex:
Y = complex(Xd(1:64),Xd(65:128))]
Method three: indexing and addition:
Y = Xd(1:64) + i*Xd(65:128)
  댓글 수: 1
abdullah qasim
abdullah qasim 2019년 1월 9일
thank u very much
for more general I make this
com = complex(Xd(1:end/2),Xd(((N)+1):end))

댓글을 달려면 로그인하십시오.

추가 답변(0개)

Community Treasure Hunt

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

Start Hunting!

Translated by