From: Bakir Kreso on 26 Mar 2010 07:15 Hello everybody, I have a text-file which looks like this: .... $ S3/460 SCHMIERSTOFFART = Polyglykol_1:1 NUE40 = 460 NUE100 = 82 RHO15 = 1.05 $ S7-150 SCHMIERSTOFFART = Polyglykol SCHMIERSTOFFBEZEICHNUNG = FVA522 S7 Grundoel NUE40 = 131 NUE100 = 21 RHO15 = 0.9943 .... The String after each $ represents the name of the oil. Now my question: I need to extract the names of the oils (e.g. "S3/460" and "S7-150") into a cell array. Can anybody help me, please? Thanks!
From: Leslie McBrayer on 26 Mar 2010 08:17 > I have a text-file which looks like this: > > ... > > $ S3/460 > > SCHMIERSTOFFART = Polyglykol_1:1 > NUE40 = 460 > NUE100 = 82 > RHO15 = 1.05 > > $ S7-150 > > SCHMIERSTOFFART = Polyglykol > SCHMIERSTOFFBEZEICHNUNG = FVA522 S7 Grundoel > NUE40 = 131 > NUE100 = 21 > RHO15 = 0.9943 > ... > > The String after each $ represents the name of the oil. Now my question: > > I need to extract the names of the oils (e.g. "S3/460" and "S7-150") into > a cell array. If the only time a $ appears in the file is immediately before an oil name, then this might work: fid = fopen('myfile.txt'); oils = textscan(fid, '%*[^$] %*c %s'); fclose(fid); In this case, %*[^$] skips everything that is not a $, %c skips the $, and %s captures the oil name.
|
Pages: 1 Prev: Multiple graphs on the same window... Next: mex compiling error with header file |