Arrangement of real and complex values of a matrix
2 次查看(过去 30 天)
显示 更早的评论
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?
0 个评论
采纳的回答
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 Exchange 中查找有关 Matrices and Arrays 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!