Finding and using the value next to a specific word in a text file!

5 visualizaciones (últimos 30 días)
Packy
Packy el 1 de Mayo de 2016
Respondida: Walter Roberson el 1 de Mayo de 2016
Hi everybody! I need to find the value of a specific variable printed in a MSC Nastran output file, which is not organized in a complete matrix. Although there isn't a unic organization, (only) the data rows of the file are organized in columns with a fixed width. The following is an extract of my file:
TRIM ALGORITHM USED: LINEAR TRIM SOLUTION WITHOUT REDUNDANT CONTROL SURFACES.
AEROELASTIC TRIM VARIABLES
ID LABEL TYPE TRIM STATUS VALUE OF UX
INTERCEPT RIGID BODY FIXED 1.000000E+00
1 ANGLEA RIGID BODY FREE 1.092527E-02 RADIANS
2 PITCH RIGID BODY FIXED 0.000000E+00 NONDIMEN. RATE
3 URDD3 RIGID BODY FIXED -9.810000E+00 LENGTH/S/S
For example, if i need to find the value associated to ANGLEA, i suppose to search the number of the row containing the string "ANGLEA (every spaces) RIGID BODY" (i'm including also the second column to avoid multiple results of searching), take it as string, and take from that string the components related to the value; for example:
val = numstr(93:104); % component from 93 to 104 of the string found in the search step
val =
1.092527E-02
Is it possible to obtain something like that? Or there are more efficient ways? thank you very much for your help!!!

Respuestas (1)

Walter Roberson
Walter Roberson el 1 de Mayo de 2016

Categorías

Más información sobre Characters and Strings en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by