|
// Matlab Interface Library
// by Emanuele Ruffaldi 2002
// http://www.sssup.it/~pit/
// mailto:pit@sssup.it
//
// Description: test of MAT File API
using System;
using EngMATLib;
namespace TestMATfiles
{
/// <summary>
/// Testing of the MAT library
/// </summary>
class Test
{
static void ListMATFile(string name)
{
using (MATFile mat = new MATFile(name, FileAccess.Read))
{
if(!mat.IsOpened)
{
Console.WriteLine("Cannot open file {0}", mat.Filename);
return;
}
NamedMatrixCollection mtx = mat.Variables;
foreach(string s in mtx.Keys)
{
Console.WriteLine(mtx[s]);
}
}
}
/// <summary>
/// The main entry point for the application.
/// </summary>
[STAThread]
static void Main(string[] args)
{
ListMATFile("demos.mat");
double[,] myma = null;
using (MATFile mat = new MATFile("demos.mat", FileAccess.Read))
{
if(mat.GetMatrix("long", ref myma))
{
Console.WriteLine("Got Matrix {0}", myma[0,0]);
}
}
using (MATFile mat = new MATFile("demos2.mat", FileAccess.Write))
{
mat.PutMatrix("hello", myma);
}
ListMATFile("demos2.mat");
}
}
}
|
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.
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
Assistant Professor in Applied Mechanics working in Virtual Reality, Robotics and having fun with Programming