in unv file they are storing data between -1 to -1

i wrote a code in c# where m calculating how many -1 are there in file.
but these code is not working.
plz help me...
thanks in advance

First, explain what an UNV file is. Unless it's a proprietary file, you should be able to find the format somewhere that will tell you how the data is layed out.

Use that to figure out how many bytes you need to read to retrieve the data you're interested in (or at least how to get to it first).

Reading the file is straightforward as you just need a simple filestream and a streamreader.

yes i know that reading the file is very easy that i already did.
you plz see the file dat i send u

With the message "My code is not working, please help me", we can do nothing to help you. Please show us your code and point out WHAT EXACTLY is not working

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;


namespace Project
{
    class Program
    {
        static void Main(string[] args)
        {
            string filename = "1.unv";
            string line = null;
            int count = 0,i=0;

           List<int> list=new List<int>();
            StreamReader reader = new StreamReader(filename);
            while ((line = reader.ReadLine()) != null)
            {
                if (line.Contains("    -1"))
                {
                    count++;
                    list.Add(count);
                }


                }
                reader.Close();
                Console.WriteLine("count:"+count);
               Console.WriteLine(list.Capacity);
                Console.WriteLine("count list:"+list.Count);
           // Console.WriteLine(list.);
                //list.Clear();

                Console.ReadLine();



            }
        }
    }

in my code m calculating how many -1 is there

Well, you've asked if a line contains 4 spaces a - sign and a 1 and so it will look for exactly that. If the line contained only 3 spaces a minus sign and a 1 then it wouldn't match.

I still don't see what file you're referring to. You have neither attached, not given a link location that contains this UNV file.

Is it a text file? If not, your code won't work anyway.

Also, what is the list for? You have a count variable, why are you adding it to a list everytime you find one?

Edited 3 Years Ago by Ketsuekiame

if u see the file u can find they are storing value in the block i.e from -1 to -1

   -1
   151
central_area_fringe_pattern.svd

PSV Version 8.7.2.0
08-Mar-11 23:30:46  
None      None      
PolyUFFExport 2.0.1.0 - Compatible to LMS
05-Jul-11 11:42:40 
    -1
    -1
   164
         1METRIC_ABS_(SI)              2
  1.00000000000000000E+00  1.00000000000000000E+00  1.00000000000000000E+00
  0.00000000000000000E+00
    -1
    -1
 2411
         1         1         1        11
  -1.9125752151012421e-02   2.8573808073997498e-01  -7.7664516866207123e-02
         2         1         1        11
  -1.9140159711241722e-02   2.8338322043418884e-01  -7.7637292444705963e-02
         3         1         1        11
  -1.9154556095600128e-02   2.8102940320968628e-01  -7.7610038220882416e-02
         4         1         1        11
  -1.9168933853507042e-02   2.7867653965950012e-01  -7.7582620084285736e-02
         5         1         1        11
  -1.9183330237865448e-02   2.7632474899291992e-01  -7.7555358409881592e-02
         6         1         1        11
  -1.9197689369320869e-02   2.7397397160530090e-01  -7.7527843415737152e-02
         7         1         1        11
  -1.9212054088711739e-02   2.7162414789199829e-01  -7.7500402927398682e-02
         8         1         1        11
  -1.9226416945457458e-02   2.6927539706230164e-01  -7.7472984790802002e-02
         9         1         1        11
  -1.9240757450461388e-02   2.6692757010459900e-01  -7.7445507049560547e-02
        10         1         1        11
  -1.9255094230175018e-02   2.6458081603050232e-01  -7.7418029308319092e-02
        11         1         1        11
  -1.9269423559308052e-02   2.6223504543304443e-01  -7.7390469610691071e-02
        12         1         1        11
  -1.9283749163150787e-02   2.5989028811454773e-01  -7.7362932264804840e-02
        13         1         1        11
  -1.9298054277896881e-02   2.5754651427268982e-01  -7.7335298061370850e-02
        14         1         1        11
  -1.6690686345100403e-02   2.9745101928710938e-01  -7.7767610549926758e-02
        15         1         1        11
  -1.6705645248293877e-02   2.9509168863296509e-01  -7.7740587294101715e-02
        16         1         1        11
  -1.6720572486519814e-02   2.9273340106010437e-01  -7.7713489532470703e-02
        17         1         1        11
  -1.6735507175326347e-02   2.9037615656852722e-01  -7.7686451375484467e-02
        18         1         1        11
  -1.6750425100326538e-02   2.8801989555358887e-01  -7.7659346163272858e-02
        19         1         1        11
  -1.6765343025326729e-02   2.8566467761993408e-01  -7.7632069587707520e-02
        20         1         1        11
  -1.6780262812972069e-02   2.8331044316291809e-01  -7.7604867517948151e-02
        21         1         1        11
  -1.6795163974165916e-02   2.8095722198486328e-01  -7.7577613294124603e-02
        22         1         1        11
  -1.6810042783617973e-02   2.7860501408576965e-01  -7.7550232410430908e-02
        23         1         1        11
  -1.6824940219521523e-02   2.7625381946563721e-01  -7.7522955834865570e-02
        24         1         1        11
  -1.6839802265167236e-02   2.7390363812446594e-01  -7.7495492994785309e-02
        25         1         1        11
  -1.6854686662554741e-02   2.7155447006225586e-01  -7.7468179166316986e-02
        26         1         1        11
  -1.6869520768523216e-02   2.6920631527900696e-01  -7.7440559864044189e-02
        27         1         1        11
  -1.6884388402104378e-02   2.6685914397239685e-01  -7.7413178980350494e-02
        28         1         1        11
  -1.6899233683943748e-02   2.6451298594474792e-01  -7.7385582029819489e-02
        29         1         1        11
  -1.6914064064621925e-02   2.6216784119606018e-01  -7.7358104288578033e-02
        30         1         1        11
  -1.6928883269429207e-02   2.5982365012168884e-01  -7.7330432832241058e-02
        31         1         1        11
  -1.6943691298365593e-02   2.5748053193092346e-01  -7.7302813529968262e-02
        32         1         1        11
  -1.6958512365818024e-02   2.5513839721679688e-01  -7.7275358140468597e-02
        33         1         1        11
  -1.6973294317722321e-02   2.5279727578163147e-01  -7.7247641980648041e-02
        34         1         1        11
  -1.6988089308142662e-02   2.5045710802078247e-01  -7.7219925820827484e-02
        35         1         1        11
  -1.7002852633595467e-02   2.4811796844005585e-01  -7.7192269265651703e-02
        36         1         1        11
  -1.7017619684338570e-02   2.4577981233596802e-01  -7.7164590358734131e-02
        37         1         1        11
  -1.4266851358115673e-02   3.0681934952735901e-01  -7.7842235565185547e-02
        38         1         1        11
  -1.4282338321208954e-02   3.0445662140846252e-01  -7.7815473079681396e-02
        39         1         1        11
  -1.4297793619334698e-02   3.0209490656852722e-01  -7.7788628637790680e-02
        40         1         1        11
  -1.4313253574073315e-02   2.9973420500755310e-01  -7.7761828899383545e-02
        41         1         1        11
  -1.4328710734844208e-02   2.9737451672554016e-01  -7.7734827995300293e-02
        42         1         1        11
  -1.4344148337841034e-02   2.9501584172248840e-01  -7.7707767486572266e-02
        43         1         1        11
  -1.4359581284224987e-02   2.9265812039375305e-01  -7.7680706977844238e-02
        44         1         1        11
  -1.4375043101608753e-02   2.9030153155326843e-01  -7.7653743326663971e-02
        45         1         1        11
  -1.4390453696250916e-02   2.8794589638710022e-01  -7.7626526355743408e-02
        46         1         1        11
  -1.4405879192054272e-02   2.8559124469757080e-01  -7.7599264681339264e-02
        47         1         1        11
  -1.4421286992728710e-02   2.8323766589164734e-01  -7.7572025358676910e-02
        48         1         1        11
  -1.4436691999435425e-02   2.8088507056236267e-01  -7.7544808387756348e-02
        49         1         1        11
  -1.4452077448368073e-02   2.7853345870971680e-01  -7.7517531812191010e-02
        50         1         1        11
  -1.4467465691268444e-02   2.7618288993835449e-01  -7.7490128576755524e-02
        51         1         1        11
  -1.4482851140201092e-02   2.7383330464363098e-01  -7.7462635934352875e-02
        52         1         1        11
  -1.4498218894004822e-02   2.7148476243019104e-01  -7.7435255050659180e-02
        53         1         1        11
  -1.4513592235743999e-02   2.6913717389106750e-01  -7.7407874166965485e-02
        54         1         1        11
  -1.4528947882354259e-02   2.6679062843322754e-01  -7.7380418777465820e-02
        55         1         1        11
  -1.4544296078383923e-02   2.6444506645202637e-01  -7.7352844178676605e-02
        56         1         1        11
  -1.4559634029865265e-02   2.6210054755210876e-01  -7.7325321733951569e-02
        57         1         1        11
  -1.4574955217540264e-02   2.5975701212882996e-01  -7.7297709882259369e-02
        58         1         1        11
  -1.4590270817279816e-02   2.5741446018218994e-01  -7.7270127832889557e-02
        59         1         1        11
  -1.4605586417019367e-02   2.5507295131683350e-01  -7.7242530882358551e-02
        60         1         1        11
  -1.4620875008404255e-02   2.5273242592811584e-01  -7.7214859426021576e-02
        61         1         1        11
  -1.4636166393756866e-02   2.5039288401603699e-01  -7.7187180519104004e-02
        62         1         1        11
  -1.4651442877948284e-02   2.4805432558059692e-01  -7.7159501612186432e-02
        63         1         1        11
  -1.4666716568171978e-02   2.4571679532527924e-01  -7.7131845057010651e-02
        64         1         1        11
  -1.4681975357234478e-02   2.4338023364543915e-01  -7.7104151248931885e-02
        65         1         1        11
  -1.4697201550006866e-02   2.4104468524456024e-01  -7.7076412737369537e-02
        66         1         1        11
  -1.4712433330714703e-02   2.3871012032032013e-01  -7.7048659324645996e-02
        67         1         1        11
  -1.4727656729519367e-02   2.3637659847736359e-01  -7.7020920813083649e-02
        68         1         1        11
  -1.1871810071170330e-02   3.1146773695945740e-01  -7.7862441539764404e-02
        69         1         1        11
  -1.1887796223163605e-02   3.0910357832908630e-01  -7.7835880219936371e-02
        70         1         1        11
  -1.1903773061931133e-02   3.0674043297767639e-01  -7.7809095382690430e-02
        71         1         1        11
  -1.1919741518795490e-02   3.0437830090522766e-01  -7.7782250940799713e-02
        72         1         1        11
  -1.1935721151530743e-02   3.0201721191406250e-01  -7.7755391597747803e-02
        73         1         1        11
  -1.1951677501201630e-02   2.9965710639953613e-01  -7.7728591859340668e-02
        74         1         1        11
  -1.1967633850872517e-02   2.9729804396629333e-01  -7.7701605856418610e-02
        75         1         1        11
  -1.1983598582446575e-02   2.9493996500968933e-01  -7.7674686908721924e-02
        76         1         1        11
  -1.1999532580375671e-02   2.9258292913436890e-01  -7.7647604048252106e-02
        77         1         1        11
  -1.2015454471111298e-02   2.9022690653800964e-01  -7.7620446681976318e-02
        78         1         1        11
  -1.2031391263008118e-02   2.8787183761596680e-01  -7.7593289315700531e-02
        79         1         1        11
  -1.2047332711517811e-02   2.8551790118217468e-01  -7.7566169202327728e-02
        80         1         1        11
  -1.2063230387866497e-02   2.8316485881805420e-01  -7.7538907527923584e-02
        81         1         1        11
  -1.2079131789505482e-02   2.8081282973289490e-01  -7.7511630952358246e-02
        82         1         1        11
  -1.2095053680241108e-02   2.7846190333366394e-01  -7.7484309673309326e-02
        83         1         1        11
  -1.2110936455428600e-02   2.7611187100410461e-01  -7.7456869184970856e-02
    -1
    -1
    58
Response Time Trace
Vib X  Velocity
08-Mar-11 23:30:46  
central_area_fringe_pattern.svd
NONE
    1         3    1         0       NONE        55   1       NONE         1   3
         2       512         1  0.00000e+00  7.81250e-07  0.00000e+00
        17    0    0    0                 Time                    s
        11    0    0    0             Velocity                  m/s
         0    0    0    0                 NONE                 NONE
         0    0    0    0                 NONE                 NONE
 -1.50835e-04  3.13650e-05  1.14108e-05  9.98143e-05  2.06276e-04  2.51925e-04
  1.85785e-04  1.87738e-05 -6.26977e-05 -1.22413e-04 -2.17667e-04 -2.48002e-04
 -1.76897e-04 -3.15502e-05  1.04802e-04  1.72459e-04  2.57814e-04  2.27192e-04
  1.33509e-04  6.97768e-06 -1.13159e-04 -1.93123e-04 -2.14538e-04 -1.72550e-04
 -7.90118e-05  3.56813e-05  1.37974e-04  1.99166e-04  2.00379e-04  1.44155e-04
  4.67742e-05 -4.70922e-05 -1.55634e-04 -2.18729e-04 -2.15132e-04 -1.54939e-04
 -5.44281e-05  6.97171e-06  1.13800e-04  2.30570e-04  2.38227e-04  1.91382e-04
  9.90575e-05  1.19921e-05 -3.02610e-05 -2.06311e-04 -2.36775e-04 -2.14522e-04
 -1.47979e-04 -5.10597e-05 -5.64917e-05  1.43499e-04  1.98799e-04  2.08278e-04
  1.71995e-04  1.01601e-04  4.29039e-05 -6.86495e-05 -1.32339e-04 -1.61756e-04
 -1.50609e-04 -1.07697e-04 -4.51401e-05 -9.40744e-06  7.02398e-05  9.22656e-05
  8.71224e-05  5.60209e-05  1.26914e-05  3.85117e-05 -4.17370e-05 -3.40174e-05
 -2.00678e-06  4.09982e-05  7.63428e-05  1.14309e-05  6.37582e-05  6.22766e-06
 -7.05118e-05 -1.21873e-04 -9.31492e-05 -4.82099e-05 -5.11157e-05 -2.98419e-05
  7.57065e-05  8.53025e-05  7.71092e-05  5.56859e-05  2.74721e-05  9.22836e-05
 -2.43707e-05 -3.93646e-05 -4.40217e-05 -4.07606e-05 -3.22639e-05 -6.92741e-05
 -9.26764e-06  1.20952e-06  9.23194e-06  1.50727e-05  2.05644e-05  2.42126e-05
  3.74933e-05  1.78317e-05  1.07579e-05  9.21274e-07 -9.53158e-06 -1.62811e-05
    -1
    -1
    58
Response Time Trace
Vib X  Velocity
08-Mar-11 23:30:46  
central_area_fringe_pattern.svd
NONE
    1         3    1         0       NONE        55   1       NONE         1   3
         2       512         1  0.00000e+00  7.81250e-07  0.00000e+00
        17    0    0    0                 Time                    s
        11    0    0    0             Velocity                  m/s
         0    0    0    0                 NONE                 NONE
         0    0    0    0                 NONE                 NONE
 -1.50835e-04  3.13650e-05  1.14108e-05  9.98143e-05  2.06276e-04  2.51925e-04
  1.85785e-04  1.87738e-05 -6.26977e-05 -1.22413e-04 -2.17667e-04 -2.48002e-04
 -1.76897e-04 -3.15502e-05  1.04802e-04  1.72459e-04  2.57814e-04  2.27192e-04
  1.33509e-04  6.97768e-06 -1.13159e-04 -1.93123e-04 -2.14538e-04 -1.72550e-04
 -7.90118e-05  3.56813e-05  1.37974e-04  1.99166e-04  2.00379e-04  1.44155e-04
  4.67742e-05 -4.70922e-05 -1.55634e-04 -2.18729e-04 -2.15132e-04 -1.54939e-04
 -5.44281e-05  6.97171e-06  1.13800e-04  2.30570e-04  2.38227e-04  1.91382e-04
  9.90575e-05  1.19921e-05 -3.02610e-05 -2.06311e-04 -2.36775e-04 -2.14522e-04
 -1.47979e-04 -5.10597e-05 -5.64917e-05  1.43499e-04  1.98799e-04  2.08278e-04
  1.71995e-04  1.01601e-04  4.29039e-05 -6.86495e-05 -1.32339e-04 -1.61756e-04
 -1.50609e-04 -1.07697e-04 -4.51401e-05 -9.40744e-06  7.02398e-05  9.22656e-05
  8.71224e-05  5.60209e-05  1.26914e-05  3.85117e-05 -4.17370e-05 -3.40174e-05
 -2.00678e-06  4.09982e-05  7.63428e-05  1.14309e-05  6.37582e-05  6.22766e-06
 -7.05118e-05 -1.21873e-04 -9.31492e-05 -4.82099e-05 -5.11157e-05 -2.98419e-05
  7.57065e-05  8.53025e-05  7.71092e-05  5.56859e-05  2.74721e-05  9.22836e-05
 -2.43707e-05 -3.93646e-05 -4.40217e-05 -4.07606e-05 -3.22639e-05 -6.92741e-05
 -9.26764e-06  1.20952e-06  9.23194e-06  1.50727e-05  2.05644e-05  2.42126e-05
  3.74933e-05  1.78317e-05  1.07579e-05  9.21274e-07 -9.53158e-06 -1.62811e-05
     -1

Edited 3 Years Ago by suryawanshi

The data looks tabbed. Try checking for "\t-1" instead.

Also there is a lot of -1 throughout the entire file. Are you interested in any in particular?

yeah there are lots of -1 bt i want to read the data block by block(i.e -1 to -1)

Is there any reason why you are putting the increment of count into list? Lines 24 25 of your code.

You say you want to read a block of -1 to -1, but there's a lot of -1's in that file. It seems you need a new way of thinking through this one because simply looking for -1 and reading everything to the next -1 is not going to work.

Personally I would parse the lot into a couple of structures based upon the knpowledge you have regarding the file and data it contains.

    %                   basic information from the file. UffDataSets will be returnedfunction [UffDataSets, Info, errmsg] = readuff(varargin)
    %READUFF Reads UFF (Universal File Format) files of types:
    %   151, 15, 55, 58, 82, 164, 2411, 2412 and also the hybrid one, 58b
    %
    %   Usage:
    %   [UffDataSets, Info, errmsg] = readuff(fileName, 'InfoOnly')  Extract only the

    %                   empty in this case.
    %
    %   [UffDataSets, Info, errmsg] = readuff(fileName) Extract the basic
    %                   information from the file as well as the whole file
    %                   contents - see the description for the UffDataSets
    %                   below.
    %
    %   [UffDataSets, Info, errmsg] = readuff(fileName, recs) Extract only the
    %                   records and their information requested by the recs
    %                   array - the array of indices, e.g., recs=[1 3 10]. If
    %                   empty, all the records are considered.
    %
    %   [UffDataSets, Info, errmsg] = readuff(..., recs, dsTypes) Extract only the
    %                   records that meet the criterria of the dsTypes where
    %                   dsTypes is an array of data-set types that are to be
    %                   read - actually, this is another filter in addition to
    %                   the recs one; e.g. dsTypes = [58 55]
    %
    %   The ouput values are:
    %   - UffDataSets:  an array of structures; each structure holds one data set
    %                   (the data set between -1 and -1; Each structure,
    %                   UffDataSets{i}, has the fields
    %                       .dsType
    %                       .binary
    %                   and some additional field which are data-set dependant
    %                   and are
    %                   as follows:
    %                   #58 - for measurement data - function at dof (58):
    %                       .d1 (description 1)     .d2 (description 2)     .date
    %                       .ID_4                   .ID_5                   .functionType (see notes)
    %                       .loadCaseId             .measData               .refEntName
    %                       .refDir                 .refNode                .rspDir
    %                       .rspEntName             .rspNode                .x (time or frequency)
    %                       .dx (abscissa spacing)   .abscissaUnitsLabel
    %                       .ordinateNumUnitsLabel  .ordinateDenumUnitsLabel
    %                       .zUnitsLabel            .zAxisValue
    %
    %                   #58b - for measurement data - the same as 58 but the data
    %                   is written in binary format
    %
    %                   #15 - coordinate data (15)  (Grid points):
    %                       .nodeN                  .defCS                  .dispCS
    %                       .color                  .x                      .y
    %                       .z
    %
    %                   #2411 - coordinate data (2411)  (Grid points):
    %                       .nodeN                  .defCS                  .dispCS
    %                       .color                  .x                      .y
    %                       .z
    %
    %                   #2412 - element data (2412):
    %                       .ElementLabel           .FEDescriptor           .PhysicalProp
    %                       .MaterialProp           .ElementColour          .NumNodes
    %                       .Elements
    %
    %                   #82 - display Sequence data (82):
    %                       .traceNum               .nNodes                 .color
    %                       .ID                     .lines
    %
    %                   #151 - header data (151):
    %                       .modelName              .description            .dateCreated
    %                       .timeCreated            .dateSaved              .timeSaved
    %                       .dbApp                  .dbVersion              .uffApp
    %
    %                   #164 - units (164):
    %                       .unitsCode              .unitsDescription       .tempMode (1=absoulute, 2=relative)
    %                       Unit factors for converting universal file units to SI. To convert from
    %                       universal file units to SI divide by the appropriate factor listed below:
    %                       .facLength              .facForce               .facTemp            
    %                       .facTempOffset
    %
    %                   #55 - data at nodes (55):
    %                       /Common fields:/
    %                       .analysisType           .dataCharacter = 1      .r1
    %                       .r2                     .r3                     .responseType
    %                       .r4                     .r5                     .r6
    %                       /Normal modes specific fields (analysisType = 2)/
    %                       .modeNum                .modeFreq               .modeMass 
    %                       .mode_v_damping_ratio   .mode_h_damping_ratio                   
    %                       /...or, for complex modes specific fields (analysisType = 3 or 7)/
    %                       .modeNum                .eigVal                 .modalA        
    %                       .modalB                 
    %                       /...or, for frequency response specific fields (analysisType = 5)/
    %                       .freqNum                .freq
    %
    %   - Info:         (optional) structure with the following fields:
    %                   .dsTypes    -   an array of data-set types read
    %                   .binary     -   an array of 1s (binary format) and 0s (ascii format)
    %                   .nDataSets  -   number of data sets found
    %                   .errcode    -   an array of error codes for each data
    %                                   set; 0 = no error otherwise an error occured in data
    %                                   set read - see errmsg
    %                   .errmsg     -   error messages (cell array of strings) for each
    %                                   data set - empty if no error occured at specific data set
    %                   .nErrors    -   number of errors found (unsupported
    %                                   datasets, error reading data set,...)
    %                   .errorMsgs  -   all the error messages (empty if no error is found)
    %   - errmsg:       (optional) general (overall), file-based error
    %                   messages - to enable reading of uncorrupted data for
    %                   example,...
    %
    %
    %   NOTES: r1..r6 are response vectors with node numbers in ROWS and
    %   direction in COLUMN (r1=x, r2=y,...,r6=rz).
    %
    %   functionType can be one of the following:
    %               0 -  General or Unknown
    %               1 -  Time Response
    %               2 -  Auto Spectrum
    %               3 -  Cross Spectrum
    %               4 -  Frequency Response Function
    %               5 -  Transmissibility
    %               6 -  Coherence
    %               7 -  Auto Correlation
    %               8 -  Cross Correlation
    %               9 -  Power Spectral Density (PSD)
    %               10 - Energy Spectral Density (ESD)
    %               11 - Probability Density Function
    %               12 - Spectrum
    %               13 - Cumulative Frequency Distribution
    %               14 - Peaks Valley
    %               15 - Stress/Cycles
    %               16 - Strain/Cycles
    %               17 - Orbit
    %               18 - Mode Indicator Function
    %               19 - Force Pattern
    %               20 - Partial Power
    %               21 - Partial Coherence
    %               22 - Eigenvalue
    %               23 - Eigenvector
    %               24 - Shock Response Spectrum
    %               25 - Finite Impulse Response Filter
    %               26 - Multiple Coherence
    %               27 - Order Function
    %
    %   analysisType can be one of the following:
    %               0: Unknown
    %               1: Static
    %               2: (supported) Normal Mode
    %               3: (supported) Complex eigenvalue first order
    %               4: Transient
    %               5: (supported) Frequency Response
    %               6: Buckling
    %               7: (supported) Complex eigenvalue second order
    %
    %   dataCharacter can be one of the following:
    %               0: Unknown
    %               1: Scalar
    %               2: 3 DOF Global Translation Vector
    %               3: 6 DOF Global Translation & Rotation Vector
    %               4: Symmetric Global Tensor
    %
    %   unitsCode can be one of the following:
    %               1 - SI: Meter (newton)
    %               2 - BG: Foot (pound f)
    %               3 - MG: Meter (kilogram f)
    %               4 - BA: Foot (poundal)
    %               5 - MM: mm (milli newton)
    %               6 - CM: cm (centi newton)
    %               7 - IN: Inch (pound f)
    %               8 - GM: mm (kilogram f)
    %
    %   functionType as well as other parameters are described in
    %   Test_Universal_File_Formats.pdf
    %
    %   Examples:
    %       [Data, Info, errmsg] = readuff('test.unv', 'InfoOnly');
    %           Extracts only the information on the content of the test.unv.
    %       [Data, Info, errmsg] = readuff('test.unv', [1 3 10]);
    %           Reads the 1st, 3rd and 10th data-set from the test.unv, while
    %       [Data, Info, errmsg] = readuff('test.unv', [1 3 10], [55, 58]);
    %           Reads the 1st, 3rd and 10th data-set from the test.unv, but,
    %           only those sets whose type is either 55 or 58.
    %       [Data, Info, errmsg] = readuff('test.unv');
    %           Reads the whole file content - all the data-sets.
    %
    %   See also: WRITEUFF
    %
    %   SOURCES:    [1] Bryce Gardner's read_uff obtained from the internet
    %               [2] http://www.sdrl.uc.edu/uff/SDRChelp/LANG/English/unv_ug/book.htm
    %
    %
    %   First release on 30.05.2004
    %   Primoz Cermelj, Slovenia
    %   Contact: primoz.cermelj@gmail.com
    %   Download location: http://www.mathworks.com/matlabcentral/fileexchange/loadFile.do?objectId=6395&objectType=file
    %
    %   Version: 1.0.5
    %   Last revision: 08.11.2008
    %
    %   Special thanks: Ben Cazzolato for adding 2411 and 2412 datasets.
    %
    %   Bug reports, questions, etc. can be sent to the e-mail given above.
    %
    %   This programme is free software; you can redistribute it and/or
    %   modify it under the terms of the GNU General Public License
    %   as published by the Free Software Foundation; either version 2
    %   of the License, or any later version.
    %
    %   This programme is distributed in the hope that it will be useful,
    %   but WITHOUT ANY WARRANTY; without even the implied warranty of
    %   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    %   GNU General Public License for more details.
    %--------------------------------------------------------------------------

    %----------------
    % READUFF history
    %----------------
    %
    % [v.1.0.1-1.0.5] 12.03.2008-08.11.2008
    % - NEW: some restrictions relaxed when reading the data-set 58
    % - NEW: some additional checking for badly formatted data-set id line
    % - NEW: some additional warning/error messages displayed for the 58b set
    % - FIX: uint8=>char instead of char=>char in fread fixes a problem on
    %        some Linux systems
    % - FIX: minor bug removed (related to the extracted abscissa values for
    %        the 58, complex case of data)
    % [v.1.0.0] 10.03.2008
    % - NEW: datasets 2411 and 2412 added
    % [v.0.9.9b1-5] 08.01.2008
    % - NEW: additional checking when reading 58b data
    % - NEW: additional filter added - dsTypes
    % - FIX: minor bug removed concerning the finding of the "    -1" tags
    % - FIX: previously, when reading data-set 58b, some data-sets were
    %        skipped; this bug is now removed
    % - NEW: new functionality to read only a portion of file and to extract
    %        the information only
    % [v.0.9.7-v.0.9.8b7] 28.02.2006
    % - FIX: a bug reading even abscissa data from the 58 set removed
    % - NEW: uneven abscissa data-reading is now supported
    % - FIX: removing leading and trailing spaces from the strings read
    % - NEW: hybrid binary-58 format (58b) is now supported
    % - NEW: binary field was added to UffDataSets structures
    % [v.0.9.7] 24.05.2005
    % - NEW: dsType field was added to UffDataSets structures
    % [v.0.9.6b4] 11.05.2005
    % - FIX: Matlab version down to 5.3 is now supported
    % - FIX: Some minor bugs removed
    % - NEW: Speed improvement; reading is much faster now
    %
    %----------------

    error(nargchk(1, 3, nargin));

    %--------------
    % Default outputs
    %--------------
    UffDataSets = [];
    Info.errcode = [];
    Info.nDataSets = 0;
    Info.dsTypes = [];
    Info.binary = [];
    Info.errmsg = [];
    Info.nErrors = 0;
    errmsg = [];


    %--------------
    % Handle input parameters
    %--------------
    recs = [];
    dsTypes = [];
    fileName = varargin{1};
    readMode = 1;   % 0=info only, 1=read all, 2=read filtered data-sets
    if nargin > 1
        if isnumeric(varargin{2}) || isempty(varargin{2})
            recs = varargin{2};
            readMode = 2;
        elseif strcmpi(varargin{2}, 'infoonly')
            readMode = 0;
        else
            error('Unknown request in the second parameter');
        end
    end
    if nargin > 2
        if isnumeric(varargin{3}) || isempty(varargin{3})
            dsTypes = varargin{3};
            readMode = 2;
        else
            error('Unknown request in the third parameter');
        end
    end


    %--------------
    % Some variables
    %--------------
    errN = 0;               % current global error number (data-set number independent)


    %--------------
    % Read the whole file data into an array of characters
    %--------------
    try
        fid = fopen(fileName, 'r');
        if fid == -1,
            errN = errN + 1;
            errmsg{errN,1} = ['could not open file: ' fileName];
            disp(errmsg{errN});
            return
        end
        FILE_DATA = (fread(fid, 'uint8=>char')).';
    catch
        errN = errN + 1;
        errmsg{errN,1} = ['error reading file contents: ' lasterr];
        disp(errmsg{errN});
        % Close the file
        fclose(fid);
        return
    end
    % Close the file
    err = fclose(fid);
    if err == -1
        errN = errN + 1;
        errmsg{errN,1} = 'error while closing file';
        disp(errmsg{errN});
    end


    %--------------
    % Find all valid blocks, data between -1 and -1; pointers to blocks of
    % data; include the first -1 but exclude the last -1;
    % the first -1 will be skipped further later on in get_block_prop
    %--------------
    ind = strfind(FILE_DATA, '    -1');
    ind     %Added
    data_len = length(FILE_DATA);
    for ii=length(ind):-1:1
        if ind(ii) == data_len
            continue
        end
        if ~isspace(FILE_DATA(ind(ii)+6))
            ind(ii) = [];
        end
        endhelp is
    nBlocks = floor(length(ind)/2);
    nBlocks      %Added
    if nBlocks < 1
        errN = errN + 1;
        errmsg{errN,1} = 'No valid blocks found';
        disp(errmsg{errN});
        return
    end
    blocks = zeros(nBlocks, 2);
    blocks(:,1) = ind(1:2:2*nBlocks)';
    blocks(:,2) = ind(2:2:2*nBlocks)'-1;


    %=============================
    % MAIN FILE LOOP - go through all the blocks and extract data from each
    % block according to the data type
    %=============================
    dataSetN = 0;       % counts VALID data-sets (including non-supported ones)
    if isempty(recs)
        recs = 1:nBlocks;
    end
    try
        if readMode==2
            readScope = recs;
            if max(recs) > nBlocks
                error('Max block number to be read is too high (%d)', max(recs));
            end
        else
            readScope = 1:nBlocks;
            readScope     %Added
        end

        for ii=readScope

            % Skips the first  -1, detects the data-set type and any possible
            % properties (e.g., for 58b there are some additional fields in the data-set
            % id record), and also returns blockLines - pointers to start and
            % end offsets of lines of the data-set-block data
            [data_set_type, DataSetProp, blockLines, errMessage] = ...
                    get_block_prop(ii, blocks(ii,1), blocks(ii,2), FILE_DATA);
            if ~isempty(errMessage)
                errN = errN + 1;
                errmsg{errN,1} = errMessage;
                continue
            end

            dataSetN = dataSetN + 1;
            ds_errmsg = [];
            if readMode~=0
                % First check if dataSetN is meets the filter
                if ~isempty(dsTypes)
                    if ~find(dsTypes==data_set_type)
                        continue
                    end
                end
                % Now, read the record
                if data_set_type == 58      % Function at nodal dof
                    [ds_data,ds_errmsg] = extract58(fileName, FILE_DATA, blockLines, DataSetProp, ii);
                elseif data_set_type == 15  % Coordinate data
                    [ds_data,ds_errmsg] = extract15(FILE_DATA, blockLines);
                elseif data_set_type == 2411  % Node Coordinate data
                    [ds_data,ds_errmsg] = extract2411(FILE_DATA, blockLines);
                elseif data_set_type == 2412  % Element data
                    [ds_data,ds_errmsg] = extract2412(FILE_DATA, blockLines);
                elseif data_set_type == 151 % Header data
                    [ds_data,ds_errmsg] = extract151(FILE_DATA, blockLines);
                elseif data_set_type == 164 % Units data
                    [ds_data,ds_errmsg] = extract164(FILE_DATA, blockLines);
                elseif data_set_type == 82  % Display sequence data
                    [ds_data,ds_errmsg] = extract82(FILE_DATA, blockLines);
                elseif data_set_type == 55  % Modal data file
                    [ds_data,ds_errmsg] = extract55(FILE_DATA, blockLines);
                else
                    ds_data = [];
                    ds_errmsg = ['unknown data-set (' num2str(data_set_type)  ') found in ' num2str(ii) '-th data-set '];
                end
                UffDataSets{dataSetN} = ds_data;
                UffDataSets{dataSetN}.dsType = data_set_type;
                UffDataSets{dataSetN}.binary = DataSetProp.binary;
            end

            Info.errmsg{dataSetN} = ds_errmsg;
            Info.dsTypes(dataSetN) = data_set_type;
            Info.binary(dataSetN) = DataSetProp.binary;
            if isempty(ds_errmsg)
                Info.errcode(dataSetN) = 0;
            else
                Info.errcode(dataSetN) = 1;
            end
        end

    catch
        errN = errN + 1;
        errmsg{errN,1} = lasterr;      
    end
    %=============================
    % END OF MAIN FILE LOOP
    %=============================


    Info.nErrors = length(find(Info.errcode));
    Info.nDataSets = dataSetN;
    Info.errorMsgs = Info.errmsg(find(Info.errcode));

    if ~isempty(errmsg)
        for ii=1:length(errmsg)
            disp(errmsg{ii});
        end
    end




    %==========================================================================
    %                       SUBFUNCTIONS SECTION
    %==========================================================================



    %--------------------------------------------------------------------------
    function [dataSet, DataSetProp, blockLines, errMessage] = get_block_prop(ds_num, so, eo, FILE_DATA)
    % Extract block-data lines' pointers (start and end for each line) and also
    % returns the data-set number identified along with any additional
    % parameters such as in the case of 58b data-set. so points to the first -1 tag
    % (designated by o): o___-1 while eo points to the end -1 tag: o___-1.
    % blockLInes are start and end offsets of each line in the current data-set
    % starting from the line right after the data-set id line.
    % Empty lines are skipped.

    % Scans for block data and returns lines' pointers (start and end offsets
    % in a 2-column matrix).

    dataSet = [];
    DataSetProp = [];
    blockLines = [];
    errMessage = [];
    try
        % For a two-column matrix of start and end indices designating the
        % start and end for each line of the data set
        blockData = FILE_DATA(so:eo);
        dataLen = length(blockData);
        lineBreaks = blockData==sprintf('\n') | blockData==sprintf('\r');
        lineBreaksInd = find(lineBreaks);
        toInd = zeros(length(lineBreaksInd)+1, 1);
        fromInd = zeros(length(lineBreaksInd)+1, 1);

        toInd(1:length(lineBreaksInd)) = lineBreaksInd-1;
        if lineBreaksInd(end) < dataLen
            toInd(length(lineBreaksInd)+1) = dataLen;
        end
        toInd = toInd(toInd>0);
        indToRemove = find(lineBreaks(toInd)==1);
        toInd(indToRemove) = [];

        if lineBreaksInd(1) > 1
            fromInd(1) = 1;
            fromInd(2:length(lineBreaksInd)+1) = lineBreaksInd+1;
        else
            fromInd(1:length(lineBreaksInd)) = lineBreaksInd+1;
        end
        if lineBreaksInd(end) == dataLen
            fromInd(length(lineBreaksInd)+1) = 0;
        end
        fromInd = fromInd(fromInd>0 & fromInd<=dataLen);
        indToRemove = find(lineBreaks(fromInd)==1);
        fromInd(indToRemove) = [];

        blockLines = [fromInd toInd];

        % The data-set line; get the data-set number
        dataSetLine = blockData(blockLines(2,1):blockLines(2,2));
        if isempty(dataSetLine) || length(dataSetLine) < 6
            warning('Badly formatted data-set id for data-set # %d', ds_num);
            dataSet = sscanf(dataSetLine, '%i', 1);
        else
            dataSet = sscanf(dataSetLine(1:6), '%i', 1);
        end
        if isempty(dataSet)
            errMessage = 'no valid data-set type found';
            return
        end

        % Get the format
        if length(dataSetLine) < 7
            format = '';
        else
            format = sscanf(dataSetLine(7), '%c', 1);
        end
        if strcmpi(format, 'b')
            DataSetProp.binary = 1;
            DataSetProp.byteOrdering = sscanf(dataSetLine(8:13),'%i',1);
            DataSetProp.fpFormat = sscanf(dataSetLine(14:19),'%i',1);
            DataSetProp.nAsciiLines = sscanf(dataSetLine(20:31),'%i',1);
            DataSetProp.nBytes = sscanf(dataSetLine(32:43),'%i',1);
            DataSetProp.d1 = sscanf(dataSetLine(44:49),'%i',1);
            DataSetProp.d2 = sscanf(dataSetLine(50:55),'%i',1);
            DataSetProp.d3 = sscanf(dataSetLine(56:67),'%i',1);
            DataSetProp.d4 = sscanf(dataSetLine(68:end),'%i',1);
        else
            DataSetProp.binary = 0;
        end

        % Global blockLines (with respect to FILE_DATA)
        blockLines = blockLines(3:end,:) + so - 1;
        if size(blockLines,1) < 2
            errMessage = 'empty data block found';
            return
        end

    catch
        errMessage = ['error while reading the header info at data set #: ' num2str(ds_num) ' (' lasterr ')'];
        return
    end




    %--------------------------------------------------------------------------
    function [UFF, errMessage] = extract58(fileName, DATA, blockLines, DataSetProp, setn)
    % #58 - Extract data-set type 58 data

    UFF = [];
    UFF.measData = [];
    errMessage = [];
    lineN = 1;
    nLines = size(blockLines, 1);

    try
        % Line 1
        UFF.d1 = strim(sscanf(DATA(blockLines(1,1):blockLines(1,2)), '%c', 80));
        lineN = lineN + 1;
        % Line 2
        UFF.d2 = strim(sscanf(DATA(blockLines(2,1):blockLines(2,2)), '%c', 80));
        lineN = lineN + 1;
        % Line 3
        UFF.date = strim(sscanf(DATA(blockLines(3,1):blockLines(3,2)), '%c', 80));
        lineN = lineN + 1;
        % Line 4
        UFF.ID_4 = strim(sscanf(DATA(blockLines(4,1):blockLines(4,2)), '%c', 80));
        lineN = lineN + 1;
        % Line 5
        UFF.ID_5 = strim(sscanf(DATA(blockLines(5,1):blockLines(5,2)), '%c', 80));
        lineN = lineN + 1;
        % Line 6
        tmpLine = DATA(blockLines(6,1):blockLines(6,2));
        tmpLine = [tmpLine repmat(' ', 1, 80-length(tmpLine))];
        UFF.functionType = sscanf(tmpLine(1:5), '%i', 1);    
        tmp = sscanf(tmpLine(6:15),'%i', 1);
        tmp = sscanf(tmpLine(16:20),'%i', 1);
        UFF.loadCaseId = sscanf(tmpLine(21:30), '%i', 1);
        UFF.rspEntName = sscanf(tmpLine(32:41), '%s', 1);
        UFF.rspNode = sscanf(tmpLine(42:51), '%i', 1);
        UFF.rspDir = sscanf(tmpLine(52:55), '%i', 1);
        UFF.refEntName = sscanf(tmpLine(57:66), '%s', 1);
        UFF.refNode = sscanf(tmpLine(67:76),'%i', 1);
        UFF.refDir = sscanf(tmpLine(77:80),'%i', 1);
        lineN = lineN + 1;

        % Line 7; data form
        tmpLine = DATA(blockLines(7,1):blockLines(7,2));
        tmpLine = [tmpLine repmat(' ', 1, 80-length(tmpLine))];
        ordDataType = sscanf(tmpLine(1:10), '%i', 1);
        numpt = sscanf(tmpLine(11:20),'%i', 1);  % # of points if even spacing or # of pairs if uneven spacing
        spacingType = sscanf(tmpLine(21:30), '%i', 1);
        UFF.xmin = sscanf(tmpLine(31:43), '%g', 1);
        UFF.dx = sscanf(tmpLine(44:56), '%g', 1);
        UFF.zAxisValue = sscanf(tmpLine(57:69), '%g', 1);
        lineN = lineN + 1;

        % Line 8; abscissa data characteristics
        tmpLine = DATA(blockLines(8,1):blockLines(8,2));
        tmpLine = [tmpLine repmat(' ',1,80-length(tmpLine))];
        abDataType = sscanf(tmpLine(1:10),'%i',1);
        tmp = sscanf(tmpLine(11:15),'%i',1);
        tmp = sscanf(tmpLine(16:20),'%i',1);
        tmp = sscanf(tmpLine(21:25),'%i',1);
        temp = sscanf(tmpLine(27:46),'%s',1);
        UFF.abscissaUnitsLabel = sscanf(tmpLine(48:end),'%s',1);
        lineN = lineN + 1;

        % Line 9; Ordinate (or ordinate numerator) Data Characteristics
        tmpLine = DATA(blockLines(9,1):blockLines(9,2));
        tmpLine = [tmpLine repmat(' ',1,80-length(tmpLine))];
        ordNumeratorDataType = sscanf(tmpLine(1:10),'%i',1);
        tmp = sscanf(tmpLine(11:15),'%i',1);
        tmp = sscanf(tmpLine(16:20),'%i',1);
        tmp = sscanf(tmpLine(21:25),'%i',1);
        tmp = sscanf(tmpLine(27:46),'%s',1);
        UFF.ordinateNumUnitsLabel = sscanf(tmpLine(48:end),'%s',1);
        lineN = lineN + 1;

        % Line 10; Ordinate Denominator Data Characteristics
        tmpLine = DATA(blockLines(10,1):blockLines(10,2));
        tmpLine = [tmpLine repmat(' ',1,80-length(tmpLine))];
        ordDenominatorDataType = sscanf(tmpLine(1:10),'%i',1);
        tmp = sscanf(tmpLine(11:15),'%i',1);
        tmp = sscanf(tmpLine(16:20),'%i',1);
        tmp = sscanf(tmpLine(21:25),'%i',1);
        temp = sscanf(tmpLine(27:46),'%s',1);
        UFF.ordinateDenumUnitsLabel = sscanf(tmpLine(48:end),'%s',1);
        lineN = lineN + 1;

        % Line 11; Z-axis Data Characteristics
        tmpLine = DATA(blockLines(11,1):blockLines(11,2));
        tmpLine = [tmpLine repmat(' ',1,80-length(tmpLine))];
        tmp = sscanf(tmpLine(1:10),'%i',1);
        tmp = sscanf(tmpLine(11:15),'%i',1);
        tmp = sscanf(tmpLine(16:20),'%i',1);
        tmp = sscanf(tmpLine(21:25),'%i',1);
        temp = sscanf(tmpLine(27:46),'%s',1);
        UFF.zUnitsLabel = sscanf(tmpLine(48:end),'%s',1);
        lineN = lineN + 1;

        % Line 12 ...; Data Values
        if DataSetProp.binary   
            %-------
            % BINARY
            %-------
            if DataSetProp.byteOrdering == 1; format = 'l'; else format = 'b'; end;
            if (ordDataType==2 || ordDataType==5)
                prec = 'float32';   % single precision
                numLen = 4;
            else
                prec = 'double';    % double precision
                numLen = 8;
            end
            fid = fopen(fileName,'r',format);
            if fid == -1
                errMessage = ['could not reopen file for binary data reading: ' fileName];
                return
            end

            % It was observed that some programs write some inconsistent values
            % to the header concerning the number of data and/or bytes the data
            % is to occupy. In case such incosistency is found, the max number
            % will be used and a warning displayed.
            % According to the UFF documentation, in the case of uneven
            % abscissa, the abscissa is always stored as real, single
            % precision.
            complexOrd = (ordDataType == 5 | ordDataType == 6);
            if spacingType == 0  % uneven
                n_ord_vals_to_read = (DataSetProp.nBytes - numpt*4)/numLen;
            else                 % even
                n_ord_vals_to_read = DataSetProp.nBytes/numLen;
            end
            n_ord_vals_to_read = n_ord_vals_to_read/(1+complexOrd);

            n_act_bytes = blockLines(end, 2) - blockLines(12,1) + 1;
            skipbytes = n_act_bytes - DataSetProp.nBytes;

            if skipbytes < 0
                errMessage = ['Badly formated binary uff file (' fileName '): '...
                              'not enough bytes of data according to the bytes '...
                              'specified in the header of the set #' num2str(setn)];
                return
            end
            if numpt ~= n_ord_vals_to_read
                warning(['Badly formated binary uff file (%s) at set #%d: the number of bytes '...
                        'specified does not match the specified number of '...
                        'values; only the data corresponding to the number '...
                        'of bytes will be read.'], fileName, setn);
            end
            if skipbytes > 0
                warning(['Badly formated binary uff file (%s) at set #%d: the size of the data '...
                        'is greater than the number of bytes specified; extra '...
                        'bytes at the beginnig will be skipped.'], fileName, setn);
            end

            status = fseek(fid, blockLines(12,1)-1+skipbytes, 'bof');
            if status
                errMessage = ['could not start reading binary data from ' fileName...
                              ' at set #' num2str(setn)];
                return
            end

            n_ord_vals_to_read = max(numpt, n_ord_vals_to_read)*(1+complexOrd);
            try
                if spacingType == 0 % uneven spacing
                    absc_values = fread(fid, numpt, 'float32', numLen*(1+complexOrd*1));                
                    fseek(fid, blockLines(12,1)-1+4+skipbytes, 'bof');
                    values = fread(fid, n_ord_vals_to_read, prec, 4);
                    if complexOrd
                        values = [absc_values; reshape(values, 2, numpt)];
                        values = reshape(values, numpt*3, 1);
                    else
                        values = [absc_values; reshape(values, 1, numpt)];
                        values = reshape(values, numpt*2, 1);
                    end
                else
                    values = fread(fid, n_ord_vals_to_read, prec);
                end
            catch
                errMessage = ['error while reading binary data from ' fileName];
                return
            end
            fclose(fid);
        else
            %------
            % ASCII
            %------
            values = sscanf(DATA(blockLines(12,1):blockLines(end,2)),'%g');
        end

        % Abscissa and ordinate values
        if (ordDataType == 2 || ordDataType == 4)        % non-complex ordinate data
            if spacingType == 0 % uneven abscissa
                UFF.x = values(1:2:end-1);
                UFF.measData = values(2:2:end);
            else                % even abscissa
                UFF.measData = values;
                nVal = length(UFF.measData);
                UFF.x = UFF.xmin : UFF.dx : UFF.xmin + (nVal-1)*UFF.dx;
            end
        elseif (ordDataType == 5 || ordDataType == 6)    % complex ordinate data
            if spacingType == 0 % uneven abscissa
                UFF.measData = values(2:3:end-1) + j*values(3:3:end);
                UFF.x = values(1:3:end-2);
            else                % even abscissa
                UFF.measData = values(1:2:end-1) + j*values(2:2:end);
                nVal = length(UFF.measData);
                UFF.x = UFF.xmin : UFF.dx : UFF.xmin + (nVal-1)*UFF.dx;
            end
        else
            errMessage = ['error reading measurement data at:' num2str(lineN)];
            return
        end

    catch
        errMessage = ['error reading measurement data: ' lasterr];
        return
    end


    %--------------------------------------------------------------------------
    function [UFF,errMessage] = extract151(DATA,blockLines)
    % #151 - Extract data-set type 151 data

    UFF = [];
    errMessage = [];
    lineN = 1;
    nLines = size(blockLines,1);

    try
        % Line 1
        UFF.modelName = strim(sscanf(DATA(blockLines(1,1):blockLines(1,2)),'%c',80));
        lineN = lineN + 1;
        % Line 2
        UFF.description = strim(sscanf(DATA(blockLines(2,1):blockLines(2,2)),'%c',80));
        lineN = lineN + 1;
        % Line 3
        UFF.dbApp = strim(sscanf(DATA(blockLines(3,1):blockLines(3,2)),'%c',80));
        lineN = lineN + 1;
        % Line 4
        tmpLine = DATA(blockLines(4,1):blockLines(4,2));
        tmpLine = [tmpLine repmat(' ',1,80-length(tmpLine))];
        UFF.dateCreated = sscanf(tmpLine(1:10),'%s',10);
        UFF.timeCreated = sscanf(tmpLine(11:20),'%s',10);
        UFF.dbVersion = sscanf(tmpLine(21:30),'%i',10);
        lineN = lineN + 1;       
        % Line 5
        tmpLine = DATA(blockLines(5,1):blockLines(5,2));
        tmpLine = [tmpLine repmat(' ',1,80-length(tmpLine))];
        UFF.dateSaved = sscanf(tmpLine(1:10),'%s',10);
        UFF.timeSaved = sscanf(tmpLine(11:20),'%s',10);
        lineN = lineN + 1;       
        % Line 6
        UFF.uffApp = strim(sscanf(DATA(blockLines(6,1):blockLines(6,2)),'%c',80));
    catch
        errMessage = ['error reading header data at line ' num2str(lineN) ' relatively to current data-set'];
        return
    end


    %--------------------------------------------------------------------------
    function [UFF,errMessage] = extract164(DATA,blockLines)
    % #164 - Extract data-set type 164 data
    UFF = [];
    errMessage = [];
    lineN = 1;
    nLines = size(blockLines,1);
    try
        % Line 1
        tmpLine = DATA(blockLines(1,1):blockLines(1,2));
        tmpLine = [tmpLine repmat(' ',1,80-length(tmpLine))];
        UFF.unitsCode = sscanf(tmpLine(1:10),'%i');    
        UFF.unitsDescription = strim(sscanf(tmpLine(11:31),'%c'));
        UFF.tempMode = sscanf(tmpLine(32:41),'%i');
        lineN = lineN + 1;
        % Line 2
        tmpLine = DATA(blockLines(2,1):blockLines(2,2));
        tmpLine = lower([tmpLine repmat(' ',1,80-length(tmpLine))]);
        tmpLine = strrep(tmpLine,'d-','e-');
        tmpLine = strrep(tmpLine,'d+','e+');
        UFF.facLength = sscanf(tmpLine(1:25),'%f');
        UFF.facForce = sscanf(tmpLine(26:50),'%f');
        UFF.facTemp = sscanf(tmpLine(51:75),'%f');
        lineN = lineN + 1;
        % Line 3
        tmpLine = DATA(blockLines(3,1):blockLines(3,2));
        tmpLine = lower([tmpLine repmat(' ',1,80-length(tmpLine))]);
        tmpLine = strrep(tmpLine,'d-','e-');
        tmpLine = strrep(tmpLine,'d+','e+');
        UFF.facTempOffset = sscanf(tmpLine(1:25),'%f');
    catch
        errMessage = ['error reading units data at line' num2str(lineN) ' relatively to current data-set: ' lasterr];
        return
    end



    %--------------------------------------------------------------------------
    function [UFF,errMessage] = extract15(DATA,blockLines)
    % #15 - Extract data-set type 15 data

    UFF = [];
    errMessage = [];
    nLines = size(blockLines,1);

    try
        values = sscanf(DATA(blockLines(1,1):blockLines(end,2)),'%g');
        nVals = length(values);
        nNodes = round(nVals/7);
        values = reshape(values,7,nNodes).';
        %
        UFF.nodeN = round(values(:,1));
        UFF.defCS = round(values(:,2));
        UFF.dispCS = round(values(:,3));
        UFF.color = round(values(:,4));
        UFF.x = values(:,5);
        UFF.y = values(:,6);
        UFF.z = values(:,7);
    catch
        errMessage = ['error reading coordinate data: ' lasterr];
        return
    end


    %--------------------------------------------------------------------------
    function [UFF,errMessage] = extract82(DATA,blockLines)
    % #82 - Extract display sequence data-set type 82 data

    UFF = [];
    errMessage = [];
    lineN = 1;
    nLines = size(blockLines,1);
    try
        % Line 1
        tmpLine = DATA(blockLines(1,1):blockLines(1,2));
        tmpLine = [tmpLine repmat(' ',1,80-length(tmpLine))];
        UFF.traceNum = sscanf(tmpLine(1:10),'%i',1);
        UFF.nNodes = sscanf(tmpLine(11:20),'%i',1);
        UFF.color = sscanf(tmpLine(21:30),'%i',1);
        lineN = lineN + 1;
        % Line 2
        UFF.ID = strim(sscanf(DATA(blockLines(2,1):blockLines(2,2)),'%c'));
        lineN = lineN + 1;
        % Line 3
        UFF.lines = sscanf(DATA(blockLines(3,1):blockLines(end,2)),'%g');
    catch
        errMessage = ['error reading trace-line data at line' num2str(lineN) ' relatively to current data-set: ' lasterr];
        return

    end




    %--------------------------------------------------------------------------
    function [UFF,errMessage] = extract55(DATA,blockLines)
    % #55 - Extract modal data-set type 55 data

    UFF = [];
    errMessage = [];
    lineN = 1;
    nLines = size(blockLines,1);
    errN = 0;

    try
        % Line 1
        UFF.d1 = strim(sscanf(DATA(blockLines(1,1):blockLines(1,2)),'%c',80));
        lineN = lineN + 1;
        % Line 2
        UFF.d2 = strim(sscanf(DATA(blockLines(2,1):blockLines(2,2)),'%c',80));
        lineN = lineN + 1;
        % Line 3
        UFF.date = strim(sscanf(DATA(blockLines(3,1):blockLines(3,2)),'%c',80));
        lineN = lineN + 1;
        % Line 4
        UFF.IDs = strim(sscanf(DATA(blockLines(4,1):blockLines(4,2)),'%c',80));
        % Line 5
        temp = sscanf(DATA(blockLines(5,1):blockLines(5,2)),'%s',1);
        lineN = lineN + 1;
        % Line 6
        tmpLine = DATA(blockLines(6,1):blockLines(6,2));
        tmpLine = [tmpLine repmat(' ',1,80-length(tmpLine))];
        UFF.modelType = sscanf(tmpLine(1:10),'%i',1);
        lineN = lineN + 1;
        if UFF.modelType ~=1,
            errMessage = ['not structural model type (line: ' num2str(lineN) ' relatively to current data-set)'];
            return
        end
        UFF.analysisType = sscanf(tmpLine(11:20),'%i',1);
        UFF.dataCharacter = sscanf(tmpLine(21:30),'%i',1);
        UFF.responseType = sscanf(tmpLine(31:40),'%i',1);
        UFF.dataType = sscanf(tmpLine(41:50),'%i',1);
        num_data_per_pt = sscanf(tmpLine(51:60),'%s',1);

        % Read records 7 and 8 which are analysis-type dependent
        if UFF.analysisType == 2  % Normal Mode
            % Line 7
            tmpLine = DATA(blockLines(7,1):blockLines(7,2));
            tmpLine = [tmpLine repmat(' ',1,80-length(tmpLine))];
            two = sscanf(tmpLine(1:10),'%i',1);
            lineN = lineN + 1;
            if two ~= 2,
                errMessage = ['unexpected value at line ' num2str(lineN) ' relatively to current data-set'];
                return
            end
            four = sscanf(tmpLine(11:20),'%i',1);
            if four ~= 4,
                errMessage = ['unexpected value at line: ' num2str(lineN) ' relatively to current data-set'];
                return
            end
            tmp = sscanf(tmpLine(21:30),'%i',1);
            UFF.modeNum = sscanf(tmpLine(31:40),'%i',1);
            % Line 8
            tmpLine = DATA(blockLines(8,1):blockLines(8,2));
            tmpLine = [tmpLine repmat(' ',1,80-length(tmpLine))];
            lineN = lineN + 1;
            UFF.modeFreq = sscanf(tmpLine(1:13),'%g',1);
            UFF.modeMass = sscanf(tmpLine(14:26),'%g',1);
            UFF.mode_v_damping_ratio = sscanf(tmpLine(27:39),'%g',1);
            UFF.mode_h_damping_ratio = sscanf(tmpLine(40:52),'%g',1);

        elseif UFF.analysisType == 3, % Complex Eigenvalue, First Order (Displacement)
            % Line 7
            tmpLine = DATA(blockLines(7,1):blockLines(7,2));
            tmpLine = [tmpLine repmat(' ',1,80-length(tmpLine))];
            lineN = lineN + 1;
            two = sscanf(tmpLine(1:10),'%i',1);
            if two ~= 2,
                errMessage = ['unexpected value at line ' num2str(lineN) ' relatively to current data-set'];
                return
            end
            six = sscanf(tmpLine(11:20),'%i',1);
            if six ~= 6,
                errMessage = ['unexpected value at line: ' num2str(lineN) ' relatively to current data-set'];
                return
            end
            tmp = sscanf(tmpLine(21:30),'%i',1);
            UFF.modeNum = sscanf(tmpLine(31:40),'%i',1);

            % Line 8
            tmpLine = DATA(blockLines(8,1):blockLines(8,2));
            tmpLine = [tmpLine repmat(' ',1,80-length(tmpLine))];
            lineN = lineN + 1;
            real_part = sscanf(tmpLine(1:13),'%g',1);
            imaginary_part = sscanf(tmpLine(14:26),'%g',1);
            UFF.eigVal = real_part + j * imaginary_part;
            real_part = sscanf(tmpLine(27:39),'%g',1);
            imaginary_part = sscanf(tmpLine(40:52),'%g',1);
            UFF.modalA = real_part + j * imaginary_part;
            real_part = sscanf(tmpLine(53:65),'%g',1);
            imaginary_part = sscanf(tmpLine(66:78),'%g',1);
            UFF.modalB = real_part + j * imaginary_part;

        elseif UFF.analysisType == 5, % Frequency Response
            % Line 7
            tmpLine = DATA(blockLines(7,1):blockLines(7,2));
            tmpLine = [tmpLine repmat(' ',1,80-length(tmpLine))];
            lineN = lineN + 1;
            two = sscanf(tmpLine(1:10),'%i',1);
            if two ~= 2,
                errMessage = ['unexpected value at line ' num2str(lineN) ' relatively to current data-set'];
                return
            end
            one = sscanf(tmpLine(11:20),'%i',1);
            if one ~= 1,            
                errMessage = ['unexpected value at line ' num2str(lineN) ' relatively to current data-set'];
                return
            end
            tmp = sscanf(tmpLine(21:30),'%i',1);
            UFF.freqNum = sscanf(tmpLine(31:40),'%i',1);

            % Line 8
            tmpLine = DATA(blockLines(8,1):blockLines(8,2));
            tmpLine = [tmpLine repmat(' ',1,80-length(tmpLine))];
            lineN = lineN + 1;
            UFF.freq = sscanf(tmpLine(1:13),'%g',1);    % in Hz

        elseif UFF.analysisType == 7  % Complex Eigenvalue, Second Order (Velocity)
            % Line 7
            tmpLine = DATA(blockLines(7,1):blockLines(7,2));
            tmpLine = [tmpLine repmat(' ',1,80-length(tmpLine))];
            lineN = lineN + 1;
            two = sscanf(tmpLine(1:10),'%i',1);
            if two ~= 2,
                errMessage = ['unexpected value at line ' num2str(lineN) ' relatively to current data-set'];
                return
            end
            six = sscanf(tmpLine(11:20),'%i',1);
            if six ~= 6,
                errMessage = ['unexpected value at line ' num2str(lineN) ' relatively to current data-set'];
                return
            end
            tmp = sscanf(tmpLine(21:30),'%i',1);
            UFF.modeNum = sscanf(tmpLine(31:40),'%i',1);

            % Line 8
            tmpLine = DATA(blockLines(8,1):blockLines(8,2));
            tmpLine = [tmpLine repmat(' ',1,80-length(tmpLine))];
            lineN = lineN + 1;
            real_part = sscanf(tmpLine(1:13),'%g',1);
            imaginary_part = sscanf(tmpLine(14:26),'%g',1);
            UFF.eigVal = real_part + j * imaginary_part;
            real_part = sscanf(tmpLine(27:39),'%g',1);
            imaginary_part = sscanf(tmpLine(40:52),'%g',1);
            UFF.modalA = real_part + j * imaginary_part;
            real_part = sscanf(tmpLine(53:65),'%g',1);
            imaginary_part = sscanf(tmpLine(66:78),'%g',1);
            UFF.modalB = real_part + j * imaginary_part;

        else
            errMessage = ['analysis type is not supported at line ' num2str(lineN) ' relatively to current data-set'];
            return
        end

        % Read response data by x,y,...components into r1..r6
        ii = 0;
        nnodes = floor((nLines-9)/2)+1;
        r1 = zeros(nnodes,1);
        r2 = r1;
        r3 = r1;
        r4 = r1;
        r5 = r1;
        r6 = r1;
        nodeNum = r1;
        for lne = 9:2:nLines-1,
            ii = ii + 1;
            %========
            %    line = 9; % line 9 type of line
            %========
            lineRead = lne;
            tmpLine = DATA(blockLines(lineRead,1):blockLines(lineRead,2));
            nodeNum(ii) = sscanf(tmpLine(1:10),'%i',1);
            lineN = lineN + 1;

            %========
            %    line = 10; % line 9 type of line
            %========
            lineRead = lne + 1;
            lineN = lineN + 1;
            tmpLine = DATA(blockLines(lineRead,1):blockLines(lineRead,2));
    %         tmpLine = [tmpLine repmat(' ',1,80-length(tmpLine))];
            if UFF.dataType == 2,       % real data
                r1(ii) = sscanf(tmpLine(1:13),'%g',1);
                r2(ii) = sscanf(tmpLine(14:26),'%g',1);
                r3(ii) = sscanf(tmpLine(27:39),'%g',1);
                if num_data_per_pt == 6,
                    r4(ii) = sscanf(tmpLine(40:52),'%g',1);
                    r5(ii) = sscanf(tmpLine(53:65),'%g',1);
                    r6(ii) = sscanf(tmpLine(66:78),'%g',1);
                end
            elseif UFF.dataType == 5,   % complex data
                p1 = sscanf(tmpLine(1:13),'%g',1);
                p2 = sscanf(tmpLine(14:26),'%g',1);
                r1(ii) = p1 + j * p2;
                p3 = sscanf(tmpLine(27:39),'%g',1);
                p4 = sscanf(tmpLine(40:52),'%g',1);
                r2(ii) = p3 + j * p4;
                p5 = sscanf(tmpLine(53:65),'%g',1);
                p6 = sscanf(tmpLine(66:78),'%g',1);
                r3(ii) = p5 + j * p6;
                if num_data_per_pt == 6,
                    errMessage = ['not setup to handle six coordinate of complex data at line ' num2str(lineN) ' relatively to current data-set'];
                    return
                end
            else
                errMessage = ['what kind of data type was that at line ' num2str(lineN) ' relatively to current data-set?'];
                return
            end
        end
        UFF.r1 = r1;
        UFF.r2 = r2;
        UFF.r3 = r3;
        UFF.r4 = r4;
        UFF.r5 = r5;
        UFF.r6 = r6;
        UFF.nodeNum = nodeNum;
    catch
        errMessage = ['error reading modal data: ' lasterr];
        return
    end


    %--------------------------------------------------------------------------
    function outstr = strim(str)
    % Removes leading and trailing spaces (spaces, tabs, endlines,...)
    % from the str string.
    if isnumeric(str);
        outstr = str;
        return
    end
    ind = find( ~isspace(str) );        % indices of the non-space characters in the str    
    if isempty(ind)
        outstr = [];        
    else
        outstr = str( ind(1):ind(end) );
    end


    %--------------------------------------------------------------------------
    function [UFF,errMessage] = extract2411(DATA,blockLines)
    % #2411 - Extract data-set type 2411 data
    % Added by Ben Cazzolato, 10/3/2008
    %
    % Universal Dataset Number 2411
    % by zopeown — last modified 2007-05-02 06:56
    % 
    % Name:   Nodes - Double Precision
    % Status: Current
    % Owner:  Simulation
    % Revision Date: 23-OCT-1992 
    % ----------------------------------------------------------------------------
    % 
    % Record 1:        FORMAT(4I10)
    %                  Field 1       -- node label
    %                  Field 2       -- export coordinate system number
    %                  Field 3       -- displacement coordinate system number
    %                  Field 4       -- color
    % Record 2:        FORMAT(1P3D25.16)
    %                  Fields 1-3    -- node coordinates in the part coordinate
    %                                   system
    %  
    % Records 1 and 2 are repeated for each node in the model.
    %  
    % Example:
    %  
    %     -1
    %   2411
    %        121         1         1        11
    %    5.0000000000000000D+00   1.0000000000000000D+00   0.0000000000000000D+00
    %        122         1         1        11
    %    6.0000000000000000D+00   1.0000000000000000D+00   0.0000000000000000D+00
    %     -1
    %  
    % ----------------------------------------------------------------------------
    UFF = [];
    errMessage = [];
    nLines = size(blockLines,1);

    try
        values = sscanf(DATA(blockLines(1,1):blockLines(end,2)),'%g');
        nVals = length(values);
        nNodes = round(nVals/7);
        values = reshape(values,7,nNodes).';
        %
        UFF.nodeN = round(values(:,1));
        UFF.defCS = round(values(:,2));
        UFF.dispCS = round(values(:,3));
        UFF.color = round(values(:,4));
        UFF.x = values(:,5);
        UFF.y = values(:,6);
        UFF.z = values(:,7);
    catch
        errMessage = ['error reading coordinate data: ' lasterr];
        return
    end


    %--------------------------------------------------------------------------
    function [UFF,errMessage] = extract2412(DATA,blockLines)
    % #2412 - Extract display sequence data-set type 82 data
    % Added by Ben Cazzolato, 10/3/2008
    %
    % Universal Dataset Number 2412
    % by zopeown — last modified 2007-05-02 06:56
    % 
    % Name:   Elements
    % Status: Current
    % Owner:  Simulation
    % Revision Date: 14-AUG-1992
    % -----------------------------------------------------------------------
    %  
    % Record 1:        FORMAT(6I10)
    %                  Field 1       -- element label
    %                  Field 2       -- fe descriptor id
    %                  Field 3       -- physical property table number
    %                  Field 4       -- material property table number
    %                  Field 5       -- color
    %                  Field 6       -- number of nodes on element
    %  
    % Record 2:  *** FOR NON-BEAM ELEMENTS ***
    %                  FORMAT(8I10)
    %                  Fields 1-n    -- node labels defining element
    %  
    % Record 2:  *** FOR BEAM ELEMENTS ONLY ***
    %                  FORMAT(3I10)
    %                  Field 1       -- beam orientation node number
    %                  Field 2       -- beam fore-end cross section number
    %                  Field 3       -- beam  aft-end cross section number
    %  
    % Record 3:  *** FOR BEAM ELEMENTS ONLY ***
    %                  FORMAT(8I10)
    %                  Fields 1-n    -- node labels defining element
    %  
    % Records 1 and 2 are repeated for each non-beam element in the model.
    % Records 1 - 3 are repeated for each beam element in the model.
    %  
    % Example:
    %  
    %     -1
    %   2412
    %          1        11         1      5380         7         2
    %          0         1         1
    %          1         2
    %          2        21         2      5380         7         2
    %          0         1         1
    %          3         4
    %          3        22         3      5380         7         2
    %          0         1         2
    %          5         6
    %          6        91         6      5380         7         3
    %         11        18        12
    %          9        95         6      5380         7         8
    %         22        25        29        30        31        26        24        23
    %         14       136         8         0         7         2
    %         53        54
    %         36       116        16      5380         7        20
    %        152       159       168       167       166       158       150       151
    %        154       170       169       153       157       161       173       172
    %        171       160       155       156
    %     -1
    % 
    % FE Descriptor Id definitions
    % ____________________________
    % 
    %    11  Rod
    %    21  Linear beam
    %    22  Tapered beam
    %    23  Curved beam
    %    24  Parabolic beam
    %    31  Straight pipe
    %    32  Curved pipe
    %    41  Plane Stress Linear Triangle
    %    42  Plane Stress Parabolic Triangle
    %    43  Plane Stress Cubic Triangle
    %    44  Plane Stress Linear Quadrilateral
    %    45  Plane Stress Parabolic Quadrilateral
    %    46  Plane Strain Cubic Quadrilateral
    %    51  Plane Strain Linear Triangle
    %    52  Plane Strain Parabolic Triangle
    %    53  Plane Strain Cubic Triangle
    %    54  Plane Strain Linear Quadrilateral
    %    55  Plane Strain Parabolic Quadrilateral
    %    56  Plane Strain Cubic Quadrilateral
    %    61  Plate Linear Triangle
    %    62  Plate Parabolic Triangle
    %    63  Plate Cubic Triangle
    %    64  Plate Linear Quadrilateral
    %    65  Plate Parabolic Quadrilateral
    %    66  Plate Cubic Quadrilateral
    %    71  Membrane Linear Quadrilateral
    %    72  Membrane Parabolic Triangle
    %    73  Membrane Cubic Triangle
    %    74  Membrane Linear Triangle
    %    75  Membrane Parabolic Quadrilateral
    %    76  Membrane Cubic Quadrilateral
    %    81  Axisymetric Solid Linear Triangle
    %    82  Axisymetric Solid Parabolic Triangle
    %    84  Axisymetric Solid Linear Quadrilateral
    %    85  Axisymetric Solid Parabolic Quadrilateral
    %    91  Thin Shell Linear Triangle
    %    92  Thin Shell Parabolic Triangle
    %    93  Thin Shell Cubic Triangle
    %    94  Thin Shell Linear Quadrilateral
    %    95  Thin Shell Parabolic Quadrilateral
    %    96  Thin Shell Cubic Quadrilateral
    %    101 Thick Shell Linear Wedge
    %    102 Thick Shell Parabolic Wedge
    %    103 Thick Shell Cubic Wedge
    %    104 Thick Shell Linear Brick
    %    105 Thick Shell Parabolic Brick
    %    106 Thick Shell Cubic Brick
    %    111 Solid Linear Tetrahedron
    %    112 Solid Linear Wedge
    %    113 Solid Parabolic Wedge
    %    114 Solid Cubic Wedge
    %    115 Solid Linear Brick
    %    116 Solid Parabolic Brick
    %    117 Solid Cubic Brick
    %    118 Solid Parabolic Tetrahedron
    %    121 Rigid Bar
    %    122 Rigid Element
    %    136 Node To Node Translational Spring
    %    137 Node To Node Rotational Spring
    %    138 Node To Ground Translational Spring
    %    139 Node To Ground Rotational Spring
    %    141 Node To Node Damper
    %    142 Node To Gound Damper
    %    151 Node To Node Gap
    %    152 Node To Ground Gap
    %    161 Lumped Mass
    %    171 Axisymetric Linear Shell
    %    172 Axisymetric Parabolic Shell
    %    181 Constraint
    %    191 Plastic Cold Runner
    %    192 Plastic Hot Runner
    %    193 Plastic Water Line
    %    194 Plastic Fountain
    %    195 Plastic Baffle
    %    196 Plastic Rod Heater
    %    201 Linear node-to-node interface
    %    202 Linear edge-to-edge interface
    %    203 Parabolic edge-to-edge interface
    %    204 Linear face-to-face interface
    %    208 Parabolic face-to-face interface
    %    212 Linear axisymmetric interface
    %    213 Parabolic axisymmetric interface
    %    221 Linear rigid surface
    %    222 Parabolic rigid surface
    %    231 Axisymetric linear rigid surface
    %    232 Axisymentric parabolic rigid surface
    % 
    % ------------------------------------------------------------------------------

    % Define all "beam like" elements since these have a different structure
    beam_like = [11,21:24,31:32,121:122];
    Largest_Num_Nodes = 20;     % This is used to zero pad the data if different element types present
    UFF = [];
    errMessage = [];
    % Initialise matrices containing field types
    ElementLabel = [];
    FEDescriptor = [];
    PhysicalProp = [];
    MaterialProp = [];
    ElementColour = [];
    NumNodes = [];
    Element = [];
    try
        values = sscanf(DATA(blockLines(1,1):blockLines(end,2)),'%g');
        nVals = length(values);
        data_remaining = 1;
        while data_remaining
            ElementLabel = [ElementLabel;round(values(1))];
            FEDescriptor = [FEDescriptor;round(values(2))];
            PhysicalProp = [PhysicalProp;round(values(3))];
            MaterialProp = [MaterialProp;round(values(4))];
            ElementColour = [ElementColour;round(values(5))];
            NumNodes = [NumNodes;round(values(6))];
            % Check for beam elements
            if sum(round(values(2))==beam_like)
                % Beam Element
                %disp('Beam Elements')
                Element = [Element;[[round(values(7:6+3+round(values(6))))]',NaN*zeros(1,Largest_Num_Nodes-3-round(values(6)))]];
                values = values(7+3+round(values(6)):end);   % Remove the element from the table
            else
                % Not Beam Element
                Element = [Element;[[round(values(7:6+round(values(6))))]',NaN*zeros(1,Largest_Num_Nodes-round(values(6)))]];
                values = values(7+round(values(6)):end);   % Remove the element from the table
            end
            if isempty(values)      % Check if any data remaining
                data_remaining=0;
            end
        end
        UFF.ElementLabel = ElementLabel;
        UFF.FEDescriptor = FEDescriptor;
        UFF.PhysicalProp = PhysicalProp;
        UFF.MaterialProp = MaterialProp;
        UFF.ElementColour = ElementColour;
        UFF.NumNodes = NumNodes;
        % Strip unnecessary columns from element matrix
        temp = find(sum(~isnan(Element))>0);
        UFF.Element = Element(:,temp);
    catch
        errMessage = ['error reading trace-line data at line' num2str(lineN) ' relatively to current data-set: ' lasterr];
        return
    end

this is the matlab code which is reading unv file.with the help of these code i have to write the code for c#...nd m nt aware of matlab code.this matlab code tells how they are extracting data from unv file

Perhaps this can do it(referring to line22 of your code):
if (line.Equals("\t-1"))
It seems your special separator is always on one line, so I guess it can only contain "\t-1" and so there would be no interference with other -1's used.

This article has been dead for over six months. Start a new discussion instead.