Question

I have a text file cTest.dat with a bunch of complex numbers in the following format:

(2.324,2432) (-1.24,-3.43) 
(2.4,0) (1.24,-8.85) 
(-2.324,4.56) (-1.24,-3.43) 

and I'd like to read them into matlab. From the help site it seems textscan would be a good choice and I try

id2=fopen('cTest.dat');
C = textscan(id2, '(%f , %f)');

However this gives me

C = [6x1 double]    [6x1 double]

Does anyone know how to do this?

Was it helpful?

Solution

You just need one more line:

C=complex(C{1,1},C{1,2})
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top