Example #1
0
        /// <summary>
        /// Set the field value at [m, n] by field No..
        /// </summary>
        /// <param name="m">The index of the rows.</param>
        /// <param name="n">The index of the columns.</param>
        /// <param name="fieldNum">The No. of the field.</param>
        /// <param name="array">The field value.</param>
        public void SetField(int m, int n, int fieldNum, mxArray array)
        {
            if (m < 0 || m >= this.M || n < 0 || n >= this.N)
            {
                throw new ArgumentOutOfRangeException("The m and n must be larger and equal than zero, and less than the rows and columns.");
            }

            if (array == null)
            {
                throw new ArgumentNullException("array", "The mxArray parameter must be not null.");
            }

            if (array.NativeObject.IsInvalid)
            {
                throw new ArgumentException("The parameter array is invalid.", "array");
            }

            int fieldCount = this.FieldCount;

            if (fieldNum < 0 || fieldNum >= fieldCount)
            {
                throw new ArgumentOutOfRangeException("fieldNum", "The fieldnum must be range from 0 to the number of the field.");
            }

            matrix.mxSetFieldByNumber(this.NativeObject, n * this.M + m, fieldNum, array.NativeObject);
        }
Example #2
0
        /// <summary>
        /// Set the field value by field No..
        /// </summary>
        /// <param name="index">The index of the struct array.</param>
        /// <param name="fieldNum">The No. of the field.</param>
        /// <param name="array">The field value.</param>
        public void SetField(int index, int fieldNum, mxArray array)
        {
            if (index < 0 || index >= this.Length)
            {
                throw new ArgumentOutOfRangeException("index", "The index must be range from 0 to the length of the array.");
            }

            if (array == null)
            {
                throw new ArgumentNullException("array", "The mxArray parameter must be not null.");
            }

            if (array.NativeObject.IsInvalid)
            {
                throw new ArgumentException("The parameter array is invalid.", "array");
            }

            int fieldCount = this.FieldCount;

            if (fieldNum < 0 || fieldNum >= fieldCount)
            {
                throw new ArgumentOutOfRangeException("fieldNum", "The fieldnum must be range from 0 to the number of the field.");
            }

            matrix.mxSetFieldByNumber(this.NativeObject, index, fieldNum, array.NativeObject);
        }
Example #3
0
        public override Array ToArray()
        {
            int m = this.M, n = this.N;

            mxArray[,] array = new mxArray[m, n];

            for (int r = 0; r < m; r++)
            {
                for (int c = 0; c < n; c++)
                {
                    array[r, c] = mxArray.Create(matrix.mxGetCell(this.NativeObject, c * m + r));
                }
            }

            return(array);
        }
Example #4
0
        /// <summary>
        /// Set the field value by field name.
        /// </summary>
        /// <param name="index">The index of the struct array.</param>
        /// <param name="fieldName">The name of field.</param>
        /// <param name="array">The field value.</param>
        public void SetField(int index, string fieldName, mxArray array)
        {
            if (index < 0 || index >= this.Length)
            {
                throw new ArgumentOutOfRangeException("index", "The index must be range from 0 to the length of the array.");
            }

            if (string.IsNullOrEmpty(fieldName))
            {
                throw new ArgumentNullException("fieldName", "The fieldName must be not null.");
            }

            if (array == null)
            {
                throw new ArgumentNullException("array", "The mxArray parameter must be not null.");
            }

            if (array.NativeObject.IsInvalid)
            {
                throw new ArgumentException("The parameter array is invalid.", "array");
            }

            matrix.mxSetField(this.NativeObject, index, fieldName, array.NativeObject);
        }
Example #5
0
        /// <summary>
        /// Set the item value of cell.
        /// </summary>
        /// <param name="m">The index of row.</param>
        /// <param name="n">The index of column.</param>
        /// <param name="array">The item of cell.</param>
        public void SetCell(int m, int n, mxArray array)
        {
            if (m < 0 || n < 0)
            {
                throw new ArgumentOutOfRangeException("The m and n must be larger than zero.");
            }

            if (m >= this.M || n >= this.N)
            {
                throw new ArgumentOutOfRangeException("The m and n must be less than the size of the cell array.");
            }

            if (array == null)
            {
                throw new ArgumentNullException("array", "The mxArray parameter must be not null.");
            }

            if (array.NativeObject.IsInvalid)
            {
                throw new ArgumentException("The parameter array is invalid.", "array");
            }

            matrix.mxSetCell(this.NativeObject, n * this.M + m, array.NativeObject);
        }
Example #6
0
        /// <summary>
        /// Set the item value of the cell.
        /// </summary>
        /// <param name="index">The index of cell items.</param>
        /// <param name="array">The item value.</param>
        public void SetCell(int index, mxArray array)
        {
            if (index < 0)
            {
                throw new ArgumentOutOfRangeException("index", "The index must be larger than zero.");
            }

            if (index >= this.Length)
            {
                throw new ArgumentOutOfRangeException("index", "The index must be less than the length of the cell array.");
            }

            if (array == null)
            {
                throw new ArgumentNullException("array", "The mxArray parameter must be not null.");
            }

            if (array.NativeObject.IsInvalid)
            {
                throw new ArgumentException("The parameter array is invalid.", "array");
            }

            matrix.mxSetCell(this.NativeObject, index, array.NativeObject);
        }
Example #7
0
        /// <summary>
        /// Set the field value at [m, n] by field name.
        /// </summary>
        /// <param name="m">The index of the rows.</param>
        /// <param name="n">The index of the columns.</param>
        /// <param name="fieldName">The field name.</param>
        /// <param name="array">The field value.</param>
        public void SetField(int m, int n, string fieldName, mxArray array)
        {
            if (m < 0 || m >= this.M || n < 0 || n >= this.N)
            {
                throw new ArgumentOutOfRangeException("The m and n must be larger and equal than zero, and less than the rows and columns.");
            }

            if (array == null)
            {
                throw new ArgumentNullException("array", "The mxArray parameter must be not null.");
            }

            if (array.NativeObject.IsInvalid)
            {
                throw new ArgumentException("The parameter array is invalid.", "array");
            }

            if (string.IsNullOrEmpty(fieldName))
            {
                throw new ArgumentNullException("fieldName", "The fieldName must be not null.");
            }

            matrix.mxSetField(this.NativeObject, n * this.M + m, fieldName, array.NativeObject);
        }
Example #8
0
        public override Array ToArray()
        {
            int m = this.M, n = this.N;
            mxArray[,] array = new mxArray[m, n];

            for (int r = 0; r < m; r++) {
                for (int c = 0; c < n; c++) {
                    array[r, c] = mxArray.Create(matrix.mxGetCell(this.NativeObject, c * m + r));
                }
            }

            return array;
        }
Example #9
0
        /// <summary>
        /// Set the item value of the cell.
        /// </summary>
        /// <param name="index">The index of cell items.</param>
        /// <param name="array">The item value.</param>
        public void SetCell(int index, mxArray array)
        {
            if (index < 0)
                throw new ArgumentOutOfRangeException("index", "The index must be larger than zero.");

            if (index >= this.Length)
                throw new ArgumentOutOfRangeException("index", "The index must be less than the length of the cell array.");

            if (array == null)
                throw new ArgumentNullException("array", "The mxArray parameter must be not null.");

            if (array.NativeObject.IsInvalid)
                throw new ArgumentException("The parameter array is invalid.", "array");

            matrix.mxSetCell(this.NativeObject, index, array.NativeObject);
        }
Example #10
0
        /// <summary>
        /// Set the item value of cell.
        /// </summary>
        /// <param name="m">The index of row.</param>
        /// <param name="n">The index of column.</param>
        /// <param name="array">The item of cell.</param>
        public void SetCell(int m, int n, mxArray array)
        {
            if (m < 0 || n < 0)
                throw new ArgumentOutOfRangeException("The m and n must be larger than zero.");

            if (m >= this.M || n >= this.N)
                throw new ArgumentOutOfRangeException("The m and n must be less than the size of the cell array.");

            if (array == null)
                throw new ArgumentNullException("array", "The mxArray parameter must be not null.");

            if (array.NativeObject.IsInvalid)
                throw new ArgumentException("The parameter array is invalid.", "array");

            matrix.mxSetCell(this.NativeObject, n * this.M + m, array.NativeObject);
        }
Example #11
0
 public bool PutVariable(string variableName, mxArray variable)
 {
     return engine.engPutVariable(this._engine, variableName, variable.NativeObject) == 0;
 }
Example #12
0
 /// <summary>
 /// Put a global value into mat file with variable name.
 /// </summary>
 /// <param name="name">The global variable name.</param>
 /// <param name="array">The global value which would put into mat file.</param>
 /// <returns>return true on success, false on error.</returns>
 public bool PutVariableAsGlobal(string name, mxArray array)
 {
     return(0 == mat.matPutVariableAsGlobal(this.NativeObject, name, array.NativeObject));
 }
Example #13
0
        /// <summary>
        /// Set the field value at [m, n] by field name.
        /// </summary>
        /// <param name="m">The index of the rows.</param>
        /// <param name="n">The index of the columns.</param>
        /// <param name="fieldName">The field name.</param>
        /// <param name="array">The field value.</param>
        public void SetField(int m, int n, string fieldName, mxArray array)
        {
            if (m < 0 || m >= this.M || n < 0 || n >= this.N)
                throw new ArgumentOutOfRangeException("The m and n must be larger and equal than zero, and less than the rows and columns.");

            if (array == null)
                throw new ArgumentNullException("array", "The mxArray parameter must be not null.");

            if (array.NativeObject.IsInvalid)
                throw new ArgumentException("The parameter array is invalid.", "array");

            if (string.IsNullOrEmpty(fieldName))
                throw new ArgumentNullException("fieldName", "The fieldName must be not null.");

            matrix.mxSetField(this.NativeObject, n * this.M + m, fieldName, array.NativeObject);
        }
Example #14
0
        /// <summary>
        /// Set the field value at [m, n] by field No..
        /// </summary>
        /// <param name="m">The index of the rows.</param>
        /// <param name="n">The index of the columns.</param>
        /// <param name="fieldNum">The No. of the field.</param>
        /// <param name="array">The field value.</param>
        public void SetField(int m, int n, int fieldNum, mxArray array)
        {
            if (m < 0 || m >= this.M || n < 0 || n >= this.N)
                throw new ArgumentOutOfRangeException("The m and n must be larger and equal than zero, and less than the rows and columns.");

            if (array == null)
                throw new ArgumentNullException("array", "The mxArray parameter must be not null.");

            if (array.NativeObject.IsInvalid)
                throw new ArgumentException("The parameter array is invalid.", "array");

            int fieldCount = this.FieldCount;
            if (fieldNum < 0 || fieldNum >= fieldCount)
                throw new ArgumentOutOfRangeException("fieldNum", "The fieldnum must be range from 0 to the number of the field.");

            matrix.mxSetFieldByNumber(this.NativeObject, n * this.M + m, fieldNum, array.NativeObject);
        }
Example #15
0
        /// <summary>
        /// Set the field value by field name.
        /// </summary>
        /// <param name="index">The index of the struct array.</param>
        /// <param name="fieldName">The name of field.</param>
        /// <param name="array">The field value.</param>
        public void SetField(int index, string fieldName, mxArray array)
        {
            if (index < 0 || index >= this.Length)
                throw new ArgumentOutOfRangeException("index", "The index must be range from 0 to the length of the array.");

            if (string.IsNullOrEmpty(fieldName))
                throw new ArgumentNullException("fieldName", "The fieldName must be not null.");

            if (array == null)
                throw new ArgumentNullException("array", "The mxArray parameter must be not null.");

            if (array.NativeObject.IsInvalid)
                throw new ArgumentException("The parameter array is invalid.", "array");

            matrix.mxSetField(this.NativeObject, index, fieldName, array.NativeObject);
        }
Example #16
0
        /// <summary>
        /// Set the field value by field No..
        /// </summary>
        /// <param name="index">The index of the struct array.</param>
        /// <param name="fieldNum">The No. of the field.</param>
        /// <param name="array">The field value.</param>
        public void SetField(int index, int fieldNum, mxArray array)
        {
            if (index < 0 || index >= this.Length)
                throw new ArgumentOutOfRangeException("index", "The index must be range from 0 to the length of the array.");

            if (array == null)
                throw new ArgumentNullException("array", "The mxArray parameter must be not null.");

            if (array.NativeObject.IsInvalid)
                throw new ArgumentException("The parameter array is invalid.", "array");

            int fieldCount = this.FieldCount;
            if (fieldNum < 0 || fieldNum >= fieldCount)
                throw new ArgumentOutOfRangeException("fieldNum", "The fieldnum must be range from 0 to the number of the field.");

            matrix.mxSetFieldByNumber(this.NativeObject, index, fieldNum, array.NativeObject);
        }
Example #17
0
 public bool PutVariable(string variableName, mxArray variable)
 {
     return(engine.engPutVariable(this._engine, variableName, variable.NativeObject) == 0);
 }
Example #18
0
 /// <summary>
 /// Put a global value into mat file with variable name.
 /// </summary>
 /// <param name="name">The global variable name.</param>
 /// <param name="array">The global value which would put into mat file.</param>
 /// <returns>return true on success, false on error.</returns>
 public bool PutVariableAsGlobal(string name, mxArray array)
 {
     return 0 == mat.matPutVariableAsGlobal(this.NativeObject, name, array.NativeObject);
 }