Click here to Skip to main content
15,895,746 members
Articles / Programming Languages / C#

1..2..3 ways of integrating MATLAB with the .NET

Rate me:
Please Sign up or sign in to vote.
4.82/5 (62 votes)
18 Nov 20037 min read 564.8K   26.1K   127  
A library to access MATLAB from .NET and a comparision of three possible methods to implement it.
// Matlab Interface Library
// by Emanuele Ruffaldi 2002
// http://www.sssup.it/~pit/
// mailto:pit@sssup.it
//
// Description: common interface to the three solutions, used by ThreeTest
using System;

namespace MATLibrary
{
	/// <summary>
	/// interface for MATLAB access
	/// this is the Maximum Common denominator between the different possibilities
	/// It's just a Demo, and in a real application you should choose one of the
	/// three solutions
	/// 
	/// Specifically the MATLAB Engine solution let use ....
	/// </summary>
	public interface MATAccess
	{
		/// <summary>
		/// Evaluates an expression and returns true on completion		
		/// </summary>
		/// <param name="expression"></param>
		/// <returns></returns>
		bool Evaluate(string expression);

		/// <summary>
		/// Say if the MATLAB window is visible
		/// </summary>
		/// <returns></returns>
		bool IsVisible();

		/// <summary>
		/// Fixes the MATLAB windows visibility
		/// </summary>
		/// <param name="b"></param>
		void SetVisible(bool b);
		
		/// <summary>
		/// Gets a matrix variable 
		/// </summary>
		/// <param name="name">name of the matrix</param>
		/// <param name="data">the matrix, preallocated or not</param>
		/// <returns></returns>
		bool GetMatrix(string name, ref double [,] data);

		/// <summary>
		/// Sets a matrix variable
		/// </summary>
		/// <param name="name">Name</param>
		/// <param name="data">Data</param>
		bool SetMatrix(string name, double [,] data);

		/// <summary>
		/// Closes the Connection to MATLAB
		/// </summary>
		void Close();
	}
}

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here


Written By
Software Developer (Senior) Scuola Superiore S.Anna
Italy Italy
Assistant Professor in Applied Mechanics working in Virtual Reality, Robotics and having fun with Programming

Comments and Discussions