How to read values from an ASCII file with several pairs of numbers within brackets?

Hi, would anyone have an idea about the simplest way to read values from an ASCII file written in the form below please? For the sample below, I would like to end up with a vector with 8 complex numbers, with values: [0.500839233-0.00349639822i; 0.500839233-0.00349639822i; 0.500839174-0.00349647552i; ...]. I have tried to first read the values using some variations of fscanf(fid,'(%f,%f)'), but it has not worked so far. Thanks.
(0.500839233,-0.00349639822) (0.500839233,-0.00349639822)
(0.500839174,-0.00349647552) (0.500839114,-0.00349660218)
(0.500839114,-0.00349676609) (0.500839174,-0.0034969002)
(0.500839233,-0.00349701941) (0.500839233,-0.00349714234)

 Respuesta aceptada

Rafa
Rafa el 25 de Ag. de 2013
Editada: Rafa el 25 de Ag. de 2013
Ops, problem solved... In case anyone has come across a similar issue, I just missed the space before each opening bracket. The following worked:
fscanf(fid,' (%f,%f)')

Más respuestas (0)

Categorías

Más información sobre Data Type Conversion en Centro de ayuda y File Exchange.

Preguntada:

el 25 de Ag. de 2013

Community Treasure Hunt

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

Start Hunting!

Translated by