フィルターのクリア

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 Center および File ExchangeResizing 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