Example #1
0
 /// <summary>
 /// Destruct the mxArray
 /// </summary>
 /// <param name="disp"></param>
 protected virtual void Dispose(bool disp)
 {
     if (max != IntPtr.Zero)
     {
         MATInvoke.mxDestroyArray(max);
         max = IntPtr.Zero;
     }
 }
Example #2
0
 protected virtual void Dispose(bool disp)
 {
     if (IsOpened)
     {
         MATInvoke.matClose(mat);
         mat = IntPtr.Zero;
     }
 }
Example #3
0
        /// <summary>
        /// Gets a matrix variable info
        /// </summary>
        /// <param name="name"></param>
        /// <returns></returns>
        public MatrixDescription GetMatrixInfo(string name)
        {
            IntPtr            pa = MATInvoke.matGetArrayHeader(mat, name);
            MatrixDescription md = new MatrixDescription(pa);

            MATInvoke.mxDestroyArray(pa);
            return(md);
        }
Example #4
0
 /// <summary>
 /// Destroy a matrix variable by name
 /// </summary>
 /// <param name="name"></param>
 /// <returns></returns>
 public bool DestroyMatrix(string name)
 {
     if (!IsOpened || mode == FileAccess.Read)
     {
         return(false);
     }
     return(MATInvoke.matDeleteArray(mat, name) == 0);
 }
Example #5
0
 protected virtual void Dispose(bool disp)
 {
     if (Active)
     {
         MATInvoke.engClose(engine);
         Marshal.FreeHGlobal(buffer);
         buffer = IntPtr.Zero;
         engine = IntPtr.Zero;
     }
 }
Example #6
0
 /// <summary>
 /// Create it from an mxArray
 /// </summary>
 /// <param name="ma"></param>
 internal MatrixDescription(IntPtr ma)
 {
     if (ma == IntPtr.Zero)
     {
         return;
     }
     Rows = MATInvoke.mxGetM(ma);
     Cols = MATInvoke.mxGetN(ma);
     Type = MATInvoke.mxGetClassID(ma);
     Name = MATInvoke.mxGetName(ma);
 }
Example #7
0
 /// <summary>
 /// Creates the connection
 /// </summary>
 public EngMATAccess(int buffersize)
 {
     engine = MATInvoke.engOpen(null);
     if (IntPtr.Zero == engine)
     {
         throw new MatlabInitFailedException();
     }
     buffer          = IntPtr.Zero;
     resultBuffer    = false;
     BufferSize      = buffersize;
     BufferingActive = true;
 }
Example #8
0
        /// <summary>
        /// Opens the specific file
        /// </summary>
        /// <param name="filename"></param>
        /// <param name="fa"></param>
        /// <returns></returns>
        public bool Open(string filename, FileAccess fa)
        {
            if (IsOpened)
            {
                return(false);
            }
            string smode = null;

            switch (fa)
            {
            case FileAccess.Read: smode = "r"; break;

            case FileAccess.Write: smode = "w"; break;

            case FileAccess.Write4: smode = "w4"; break;

            case FileAccess.Update: smode = "u"; break;
            }
            this.filename = filename;
            this.mode     = fa;
            mat           = MATInvoke.matOpen(filename, smode);
            return(IsOpened);
        }
Example #9
0
 /// <summary>
 /// Say if the MATLAB window is visible
 /// </summary>
 /// <returns></returns>
 public bool IsVisible()
 {
     return(MATInvoke.engIsVisible(engine));
 }
Example #10
0
 /// <summary>
 /// Evaluates an expression and returns true on completion
 /// </summary>
 /// <param name="expression"></param>
 /// <returns></returns>
 public bool Evaluate(string expression)
 {
     return(MATInvoke.engEvalString(engine, expression) == 0);
 }
Example #11
0
 /// <summary>
 /// Creates a Matrix with the specific type
 /// </summary>
 /// <param name="rows"></param>
 /// <param name="cols"></param>
 /// <param name="t"></param>
 public Matrix(int rows, int cols, Type t)
 {
     MATInvoke.mxClassID tt = MATInvoke.Type2ClassID(t);
     max = MATInvoke.mxCreateNumericMatrix(rows, cols, tt, MATInvoke.mxComplexity.mxREAL);
 }
Example #12
0
 /// <summary>
 /// Creates a 3 dimensional matrix, for Image Processing
 /// </summary>
 /// <param name="rows"></param>
 /// <param name="cols"></param>
 /// <param name="planes"></param>
 /// <param name="t"></param>
 public Matrix(int rows, int cols, int planes, Type t)
 {
     int [] dims            = { rows, cols, planes };
     MATInvoke.mxClassID tt = MATInvoke.Type2ClassID(t);
     max = MATInvoke.mxCreateNumericArray(3, dims, tt, MATInvoke.mxComplexity.mxREAL);
 }
Example #13
0
 /// <summary>
 /// Creates an empty Matrix rows x columns
 /// </summary>
 /// <param name="rows"></param>
 /// <param name="cols"></param>
 public Matrix(int rows, int cols)
 {
     max = MATInvoke.mxCreateDoubleMatrix(rows, cols, MATInvoke.mxComplexity.mxREAL);
 }
Example #14
0
 /// <summary>
 /// Fixes the MATLAB windows visibility
 /// </summary>
 /// <param name="b"></param>
 public void SetVisible(bool b)
 {
     MATInvoke.engSetVisible(engine, b);
 }