MATLAB Answers

0

How can I delete the imaginary part of an array?

Asked by hiroki konno on 12 Jul 2018
Latest activity Commented on by hiroki konno on 13 Jul 2018
>> A = rand(1,4)+1i*rand(1,4);
>> B = rand(1,4);
>> C = vertcat(A,B)
C =
0.6491 + 0.5470i 0.7317 + 0.2963i 0.6477 + 0.7447i 0.4509 + 0.1890i
0.6868 + 0.0000i 0.1835 + 0.0000i 0.3685 + 0.0000i 0.6256 + 0.0000i
Then I want to change the elements of complex numbers to NaN.
C =
NaN NaN NaN NaN
0.6868 + 0.0000i 0.1835 + 0.0000i 0.3685 + 0.0000i 0.6256 + 0.0000i
How can I do?

  0 Comments

Sign in to comment.

1 Answer

Answer by Torsten
on 12 Jul 2018
Edited by Torsten
on 12 Jul 2018

C(C~=real(C)) = NaN;

  1 Comment

Sign in to comment.