1 | /* |
---|
2 | * ---------------------------------------------------------------------- |
---|
3 | * INTERFACE: Matlab Rappture Library Source |
---|
4 | * |
---|
5 | * [retVal,err] = rpUnitsGetExponent(unitsHandle) |
---|
6 | * |
---|
7 | * ====================================================================== |
---|
8 | * AUTHOR: Derrick Kearney, Purdue University |
---|
9 | * Copyright (c) 2004-2012 HUBzero Foundation, LLC |
---|
10 | * |
---|
11 | * See the file "license.terms" for information on usage and |
---|
12 | * redistribution of this file, and for a DISCLAIMER OF ALL WARRANTIES. |
---|
13 | * ====================================================================== |
---|
14 | */ |
---|
15 | |
---|
16 | #include "RpMatlabInterface.h" |
---|
17 | |
---|
18 | /**********************************************************************/ |
---|
19 | // METHOD: [retVal,err] = rpUnitsGetExponent(unitHandle) |
---|
20 | /// Return the exponent of the Rappture Unit represented by unitHandle. |
---|
21 | /** |
---|
22 | * Retrieve the exponent of the Rappture Units object with the handle` |
---|
23 | * 'unitHandle'. Return the exponent as a double. |
---|
24 | * Error code, err=0 on success, anything else is failure. |
---|
25 | */ |
---|
26 | |
---|
27 | void mexFunction(int nlhs, mxArray *plhs[], |
---|
28 | int nrhs, const mxArray *prhs[]) |
---|
29 | { |
---|
30 | int unitsHandle = 0; |
---|
31 | const RpUnits* unitsObj = NULL; |
---|
32 | const char* retString = NULL; |
---|
33 | double retVal = 0.0; |
---|
34 | int err = 1; |
---|
35 | |
---|
36 | /* Check for proper number of arguments. */ |
---|
37 | if (nrhs != 1) |
---|
38 | mexErrMsgTxt("Two input required."); |
---|
39 | else if (nlhs > 2) |
---|
40 | mexErrMsgTxt("Too many output arguments."); |
---|
41 | |
---|
42 | unitsHandle = getIntInput(prhs[0]); |
---|
43 | |
---|
44 | /* Call the C subroutine. */ |
---|
45 | if (unitsHandle > 0) { |
---|
46 | unitsObj = getObject_UnitsStr(unitsHandle); |
---|
47 | if (unitsObj) { |
---|
48 | retVal = unitsObj->getExponent(); |
---|
49 | err = 0; |
---|
50 | } |
---|
51 | } |
---|
52 | |
---|
53 | /* Set C-style string output_buf to MATLAB mexFunction output*/ |
---|
54 | plhs[0] = mxCreateDoubleScalar(retVal); |
---|
55 | plhs[1] = mxCreateDoubleScalar(err); |
---|
56 | |
---|
57 | return; |
---|
58 | } |
---|