Exemplo n.º 1
0
def testmax():
    '''
    Testing that an example I put in the README
    actually compiles and runs correctly.
    '''
    import numpy
    import matlab
    x = numpy.array([1,2,4,0])
    val, ind = matlab.max(x, nargout=2)
    matlab.fprintf("Max of %r is %r at 1-based index %r\n" % (x, val, ind))
Exemplo n.º 2
0
def testmax():
    '''
    Testing that an example I put in the README
    actually compiles and runs correctly.
    '''
    import numpy
    import matlab
    x = numpy.array([1, 2, 4, 0])
    val, ind = matlab.max(x, nargout=2)
    matlab.fprintf("Max of %r is %r at 1-based index %r\n" % (x, val, ind))
Exemplo n.º 3
0
def run():
    x = arange(0,5.1,0.1)
    s = sin(x)
    c = cos(x)
    # Python's normal printing capability doesn't work
    # unless you're using MATLAB without the GUI.
    # Use MATLAB's printing and reading functions.
    fprintf("Type of x: %r\n" % type(x))
    fprintf("Type of s: %r\n" % type(s))
    fprintf("Type of c: %r\n" % type(c))
    fprintf("mxclass of c: %s\n" % _class(c))
    # Currently pymex will try to coerce all function
    # arguments to MATLAB types if it can. This should
    # probably be configurable using keyword args...
    plot(x, s, x, c)
Exemplo n.º 4
0
def run():
    x = arange(0, 5.1, 0.1)
    s = sin(x)
    c = cos(x)
    # Python's normal printing capability doesn't work
    # unless you're using MATLAB without the GUI.
    # Use MATLAB's printing and reading functions.
    fprintf("Type of x: %r\n" % type(x))
    fprintf("Type of s: %r\n" % type(s))
    fprintf("Type of c: %r\n" % type(c))
    fprintf("mxclass of c: %s\n" % _class(c))
    # Currently pymex will try to coerce all function
    # arguments to MATLAB types if it can. This should
    # probably be configurable using keyword args...
    plot(x, s, x, c)