[97] | 1 | /* |
---|
| 2 | * ---------------------------------------------------------------------- |
---|
| 3 | * INTERFACE: Matlab Rappture Library Source |
---|
| 4 | * |
---|
[154] | 5 | * [retVal,err] = rpUnitsGetExponent(unitsHandle) |
---|
[97] | 6 | * |
---|
| 7 | * ====================================================================== |
---|
| 8 | * AUTHOR: Derrick Kearney, Purdue University |
---|
[115] | 9 | * Copyright (c) 2004-2005 Purdue Research Foundation |
---|
| 10 | * |
---|
| 11 | * See the file "license.terms" for information on usage and |
---|
| 12 | * redistribution of this file, and for a DISCLAIMER OF ALL WARRANTIES. |
---|
[97] | 13 | * ====================================================================== |
---|
| 14 | */ |
---|
| 15 | |
---|
| 16 | #include "RpMatlabInterface.h" |
---|
| 17 | |
---|
[154] | 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 | |
---|
[97] | 27 | void mexFunction(int nlhs, mxArray *plhs[], |
---|
| 28 | int nrhs, const mxArray *prhs[]) |
---|
| 29 | { |
---|
[141] | 30 | int unitsHandle = 0; |
---|
| 31 | const RpUnits* unitsObj = NULL; |
---|
| 32 | const char* retString = NULL; |
---|
| 33 | double retVal = 0.0; |
---|
[154] | 34 | int err = 1; |
---|
[97] | 35 | |
---|
| 36 | /* Check for proper number of arguments. */ |
---|
| 37 | if (nrhs != 1) |
---|
| 38 | mexErrMsgTxt("Two input required."); |
---|
[154] | 39 | else if (nlhs > 2) |
---|
[97] | 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(); |
---|
[154] | 49 | err = 0; |
---|
[97] | 50 | } |
---|
| 51 | } |
---|
| 52 | |
---|
| 53 | /* Set C-style string output_buf to MATLAB mexFunction output*/ |
---|
| 54 | plhs[0] = mxCreateDoubleScalar(retVal); |
---|
[154] | 55 | plhs[1] = mxCreateDoubleScalar(err); |
---|
[97] | 56 | |
---|
| 57 | return; |
---|
| 58 | } |
---|