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

3 Ansichten (letzte 30 Tage)
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)

Akzeptierte Antwort

Rafa
Rafa am 25 Aug. 2013
Bearbeitet: Rafa am 25 Aug. 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)')

Weitere Antworten (0)

Community Treasure Hunt

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

Start Hunting!

Translated by