Read from file

10 Ansichten (letzte 30 Tage)
Andrea Ferrari
Andrea Ferrari am 5 Mär. 2012
Hi all,
How can i read a file with this format:
x1 (((x2 x3 x4) (x5 x6 x7)) ((x8 x9 x10) (x11 x12 x13)))
where x_n are numbers. I do not know how to skip the brackets.
Regards
Andrea
  1 Kommentar
Jan
Jan am 5 Mär. 2012
What is the desired output?

Melden Sie sich an, um zu kommentieren.

Antworten (1)

Ken Atwell
Ken Atwell am 5 Mär. 2012
If you really want to just ignore the the parenthesis, you can treat them as "whitespace" characters in a call to textscan:
f = fopen('test.dat')
data=textscan(f, '%f', 'Whitespace', ' \b\t()')
fclose(f)
"data" will be a 1x1 cell array containing a numeric array with your data.

Kategorien

Mehr zu Data Import and Analysis finden Sie in Help Center und File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by