Finding value behind string
3 views (last 30 days)
I'd like to screen a text-dokument (with numeric values and character-strings in a header section which is repeated every N rows; and numeric values in form of a matrix underneath the header) and collect all values after a certain string. The value stands periodically (alone) in the next line of a certain string.
How is it possible to collect all these values in an array?
Thanks a lot in advance, kind regards
Richard on 12 Apr 2012
Couldn't you import all of the text file into matlab using textscan and then select the appropriate fields afterwards? It may prove to be easier to deal with the document once it is in matlab rather than trying to select the required fields directly from the text file.
More Answers (1)
Image Analyst on 12 Apr 2012
How about using fread(), fgetl(), and fclose()? Open the file, call fgetl() a number of times to read and throw away the header, then read the line you want and extract the value. You could use fscanf(), textscan(), str2double() and maybe some other ways. Can you give an example of the line of text that contains the value(s) you want to extract?