source: trunk/src/matlab/rpGetUnits.cc @ 97

Last change on this file since 97 was 97, checked in by dkearney, 19 years ago

adding initial matlab bindings
few minor changes with other listed files

File size: 1.2 KB
Line 
1/*
2 * ----------------------------------------------------------------------
3 *  INTERFACE: Matlab Rappture Library Source
4 *
5 *    retStr = rpGetUnits(unitsHandle)
6 *
7 * ======================================================================
8 *  AUTHOR:  Derrick Kearney, Purdue University
9 *  Copyright (c) 2005
10 *  Purdue Research Foundation, West Lafayette, IN
11 * ======================================================================
12 */
13
14#include "RpMatlabInterface.h"
15
16void mexFunction(int nlhs, mxArray *plhs[],
17                 int nrhs, const mxArray *prhs[])
18{
19    int         unitsHandle = 0;
20    RpUnits*    unitsObj    = NULL;
21    const char* retString   = NULL;
22
23    /* Check for proper number of arguments. */
24    if (nrhs != 1)
25        mexErrMsgTxt("Two input required.");
26    else if (nlhs > 1)
27        mexErrMsgTxt("Too many output arguments.");
28
29    unitsHandle = getIntInput(prhs[0]);
30
31    /* Call the C subroutine. */
32    if (unitsHandle > 0) {
33        unitsObj = getObject_UnitsStr(unitsHandle);
34        if (unitsObj) {
35            retString = unitsObj->getUnits().c_str();
36        }
37    }
38
39    /* Set C-style string output_buf to MATLAB mexFunction output*/
40    plhs[0] = mxCreateString(retString);
41
42    return;
43}
Note: See TracBrowser for help on using the repository browser.