0

I am trying to have Matlab read a .unv file (which is seems to open just fine and treats as a .txt) and gather data. An example from the first part of the file is as follows:

-1
   151
bricktest.unv

CUBIT version 14.0 revised 2013-06-01 09:06:37 -0600 (Sat, 01 Jun 2013)
  03-07-13  14:14:00         0         0         0
  03-07-13  14:14:00
CUBIT
  03-07-13  14:14:00
    -1
    -1
   164
        10mm (newton)                  2
  1.00000000000000000D+03  1.00000000000000000D+00  1.00000000000000000D+00
  2.73149999999999960D+02
    -1
    -1
  1716

======================================================================
MATERIAL
======================================================================



    100  Default-Steel
         0  LINE(S) OF TEXT
         0  MATERIAL CLASS(ES):
         0  MATERIAL ATTRIBUTE(S)
         0  MATERIAL COMPONENT(S)
         0  MATERIAL SPECIFICATION(S)
----------------------------------------------------------------------
         0  MATERIAL VARIABLE(S)
----------------------------------------------------------------------
         4  MATERIAL PROPERT(IES)
----------------------------------------------------------------------
MODULUS OF ELASTICITY
         1  VERSION NUMBER
         0  LINE(S) OF TEXT
DIMENSIONS AND UNITS:
PRESSURE                                NEWTON/MILLIMETER^2
CONSTANT
  2.0680000000000000e+005
----------------------------------------------------------------------
POISSONS RATIO
         1  VERSION NUMBER
         0  LINE(S) OF TEXT
DIMENSIONS AND UNITS:
DIMENSIONLESS                           UNITLESS
CONSTANT
  2.8999999999999998e-001
----------------------------------------------------------------------
SHEAR MODULUS
         1  VERSION NUMBER
         0  LINE(S) OF TEXT
DIMENSIONS AND UNITS:
PRESSURE                                NEWTON/MILLIMETER^2
CONSTANT
  8.0155039000000004e+004
----------------------------------------------------------------------
MASS DENSITY
         1  VERSION NUMBER
         0  LINE(S) OF TEXT
DIMENSIONS AND UNITS:
MASS DENSITY                            GRAM/MILLIMETER^3
CONSTANT
  6.9999999999999999e-006
----------------------------------------------------------------------
DEFAULT MATERIAL PROPERT(IES):
MODULUS OF ELASTICITY                   VERSION :          1
POISSONS RATIO                          VERSION :          1
MASS DENSITY                            VERSION :          1
SHEAR MODULUS                           VERSION :          1
----------------------------------------------------------------------
         1  REFERENCE ENTITIES
         1  MATERIAL TYPES
FEM                                     ISOTROPIC MATERIALS
======================================================================
    -1
    -1
  2470

The first 11 lines are not really very pertinent to me at this point. I have decoded this output to the point where I know "1716" indicates the beginning of material property definitions. In this file there is only one material, but in other files there can be a whole bunch, each preceded by the "1716".

I would like to be able to at this point ignore the first 11 lines, and then have Matlab store material property data, but since I don't know how many materials will be present, I need to recognize the value "1716" and if it appears, read in a new material.

The number "2420" at the very end also indicates a different kind of dataset (of unknown length) so eventually I would like to just search through the document for these markers and save the data in arrays and such based on them.

I have played with textscan but am having trouble ... thoughts?

Kate Gregory
  • 18,808
  • 8
  • 56
  • 85
  • Maybe have a look at [`regular expressions`](http://www.mathworks.com/help/matlab/matlab_prog/regular-expressions.html) in Matlab. That would allow you to actually search for reoccurring strings, such as `MATERIAL`. – Schorsch Jul 09 '13 at 18:21
  • If possible, I would recommend using, e.g. python or something better for processing txt files of "strange" structure into e.g. csv files that matlab can easily read. Matlab's txt and str processing tools are not very good. – Marcin Jul 10 '13 at 04:44

0 Answers0