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

3 次查看(过去 30 天)
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)

采纳的回答

Rafa
Rafa 2013-8-25
编辑:Rafa 2013-8-25
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)')

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Logical 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by