matlab_loadΒΆ

matlab_load loads a MATLAB file (mat file) into a UniScript object.

obj = matlab_load(ssFileName)

Return Value

obj is a UniScript object. If an error occurs, an error object is returned (see error_create).

Parameters

ssFileName

ssFileName is the name of the MATLAB file. MATLAB files normally carry the file extension .mat.

Example

def test_matlab_load()
{
    // Create an UniScript-Object

    o = [.]
    o.x = linspace(0, 2*PI, 100);
    o.y = sin(o.x);

    ssFile = GetTempPath() + "test.mat"
    err = matlab_save(o, ssFile);
    if (type(err) == "error") {
        error("Cant write " + ssFile + " (" + err.message + ")");
    }

    o_res = matlab_load(ssFile);
    if (type(err) == "error") {
        error("Cant load " + ssFile + " (" + err.message + ")");
    }
}

test_matlab_load()

Comment

Sparse matrices can be converted to a valid matrix with the following function:

def FullMatrix(mSparse)
{
    dims = mSparse.dims;
    ir = mSparse.ir;
    jc = mSparse.jc;
    p = mSparse.p;
    m = zeros(dims);
    for (i in 1:len(p)) {
        m[ir[i]; jc[i]] = p[i];
    }
    return m;
}

History

Version Description
R2013.3 Support of mxINT64_CLASS, mxUINT64_CLASS and mxFUNCTION_CLASS.
5.10.2 Support for MAT-4 files and support for big-endian byte order.
5.10.0 New

id-1988090