필터 지우기
필터 지우기

Arrangement of real and complex values of a matrix

조회 수: 1 (최근 30일)
Karthik Nagaraj
Karthik Nagaraj 2021년 7월 19일
댓글: Karthik Nagaraj 2021년 7월 19일
A square matrix M of order N x N consists of real and complex valued entries as each element. The requirement is to extend the matrix by splitting real and imaginary values along rows. So the new matrix is of order 2N x N.
Right now I have the code below which does it well. But drawback with this the arrangement is all real values are displayed first and then imaginary parts.
Mr=real(M);
Mc=imag(M);
Mf=[Mr;Mc];
I need to store the new matrix in the form of real and imaginary ordered pair like the final matrix should have
[r1,1 r1,2 ...... r1,15
c1,1 c1,2 .... c1,15
.
.
.
r1,15 r2,15...r15,15
c1,15 c2,15....c15,15]
How to modify the present code?

채택된 답변

KSSV
KSSV 2021년 7월 19일
A = rand(5)+1i*rand(5) ;
[m,n] = size(A) ;
iwant = zeros(2*m,n) ;
iwant(1:2:end,:) = real(A) ;
iwant(2:2:end,:) = imag(A) ;

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Resizing and Reshaping Matrices에 대해 자세히 알아보기

태그

제품


릴리스

R2019b

Community Treasure Hunt

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

Start Hunting!

Translated by