Contents Previous Next Subchapters

Reading an O-Matrix Native Format Binary File
Syntax D = omread(file)
[D, valueName] = omread(
file)
[D, valueName, variableNames] = omread(
file)
[D, valueName, variableNames, createDate] = omread(
file)
See Also omwrite , write , read , time , clock

Description
Loads the data stored in file file which was created with the omwrite function. The returned value D is the same type and size as was created with omwrite. If the file name file does not include a suffix, the omread function will append the string .OMD to file.

If specified, the returned value valueName is a character row vector which is the name of the variable stored in file. If specified, the returned value variableNames is a character matrix where each row of variableNames is the name of each column of data in D. The number of rows in variableNames is less than or equal the column dimension of D. If specified, the returned value createDate is a character row vector which contains the time that file was created. The format of createDate is the same as the clock function.

Examples
If you enter,
    D = {[1.1, 1.2], [2.1, 2.2], [3.1, 3.2]}
    omwrite("tst", D)
    D = omread("tst")
    print type(D)
    print D
O-Matrix will create a file tst.OMD, load the data from the file, print the type of the data that was stored in tst.OMD and then print the value of the data.
    real
    {
    [ 1.1 , 1.2 ]
    [ 2.1 , 2.2 ]
    [ 3.1 , 3.2 ]
    }

Specifying valueName
If you continue the example by entering
    [matrix, valueName] = omread("tst")
    print valueName
O-Matrix will print the name of the data variable when it was created. Note that the variable that omread assigns to, e.g. matrix above, does not need to be the same name as when the file was created.
    D

Specifying variableNames
If you enter
    omwrite("NamedData.dat", D, {"Column 1", "Col 2"})
O-Matrix will create the file NamedData.dat in the current working directory which contains the variable D and the strings "Column 1" and "Col 2". If you continue by entering,
    [D, valueName, varNames] = omread("NamedData.dat")
    print varNames.row(1)
    print varNames.row(2)
O-Matrix will print each of the stored strings that represent the names of the first 2 columns in D.
    Column 1
    Col 2

Specifying createDate
If you continue by entering
    [D, valueName, varNames, createDate] = omread("NamedData.dat")
    print createDate
O-Matrix will print the date and time that the file NamedData.dat was created.

If the value stored by omwrite is an expression value, that is not a named variable then the value of valueName is t#### where #### is the number of microseconds that O-Matrix had been running when fileName was created. If you enter,
    clear
    R = rand(10000,300)
    omwrite("C.OMD", R * 1i0)
    [C, valueName] = omread("C.OMD")
    print valueName
O-Matrix will print a value of the form
    t3429157