Azzera filtri
Azzera filtri

Arrangement of real and complex values of a matrix

1 visualizzazione (ultimi 30 giorni)
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?

Risposta accettata

KSSV
KSSV il 19 Lug 2021
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) ;

Più risposte (0)

Categorie

Scopri di più su Resizing and Reshaping Matrices in Help Center e File Exchange

Prodotti


Release

R2019b

Community Treasure Hunt

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

Start Hunting!

Translated by