Arrangement of real and complex values of a matrix

1 visualización (últimos 30 días)
Karthik Nagaraj
Karthik Nagaraj el 19 de Jul. de 2021
Comentada: Karthik Nagaraj el 19 de Jul. de 2021
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?

Respuesta aceptada

KSSV
KSSV el 19 de Jul. de 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) ;

Más respuestas (0)

Categorías

Más información sobre Resizing and Reshaping Matrices en Help Center y File Exchange.

Etiquetas

Productos


Versión

R2019b

Community Treasure Hunt

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

Start Hunting!

Translated by