[97] | 1 | /* |
---|
| 2 | * ---------------------------------------------------------------------- |
---|
| 3 | * INTERFACE: Matlab Rappture Library Source |
---|
| 4 | * |
---|
[135] | 5 | * [unitsHandle] = rpUnitsDefineUnit(unitSymbol, basisHandle) |
---|
[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 | |
---|
| 18 | void mexFunction(int nlhs, mxArray *plhs[], |
---|
| 19 | int nrhs, const mxArray *prhs[]) |
---|
| 20 | { |
---|
| 21 | char *unitSymbol = NULL; |
---|
[141] | 22 | const RpUnits* basis = NULL; |
---|
[97] | 23 | RpUnits* myUnit = NULL; |
---|
| 24 | int retHandle = 0; |
---|
| 25 | int basisHandle = 0; |
---|
| 26 | int retIndex = 0; |
---|
| 27 | |
---|
| 28 | /* Check for proper number of arguments. */ |
---|
| 29 | if (nrhs != 2) |
---|
| 30 | mexErrMsgTxt("Two input required."); |
---|
| 31 | else if (nlhs > 1) |
---|
| 32 | mexErrMsgTxt("Too many output arguments."); |
---|
| 33 | |
---|
| 34 | unitSymbol = getStringInput(prhs[0]); |
---|
| 35 | basisHandle = getIntInput(prhs[1]); |
---|
| 36 | |
---|
| 37 | /* Call the C subroutine. */ |
---|
| 38 | if (basisHandle > 0) { |
---|
| 39 | basis = getObject_UnitsStr(basisHandle); |
---|
| 40 | } |
---|
| 41 | |
---|
| 42 | if (unitSymbol) { |
---|
| 43 | myUnit = RpUnits::define(unitSymbol,basis); |
---|
| 44 | |
---|
| 45 | if (myUnit) { |
---|
| 46 | retHandle = storeObject_UnitsStr(myUnit->getUnitsName()); |
---|
| 47 | } |
---|
| 48 | } |
---|
| 49 | |
---|
| 50 | /* Set C-style string output_buf to MATLAB mexFunction output*/ |
---|
| 51 | plhs[0] = mxCreateDoubleScalar(retHandle); |
---|
| 52 | |
---|
| 53 | return; |
---|
| 54 | } |
---|