I am currently using this preliminary code:
static void Main(string[] args)
{
try
{
Type matlabtype;
matlabtype = Type.GetTypeFromProgID("matlab.application");
object matlab;
matlab = Activator.CreateInstance(matlabtype);
Execute(matlabtype, matlab, "clear;");
Execute(matlabtype, matlab, "path(path,'H:/bla/bla');");
Execute(matlabtype, matlab, "Object = ClassName();");
Execute(matlabtype, matlab, "Object.parameter1 = 100;");
Execute(matlabtype, matlab, "Object.parameter2 = 300;");
object o = Execute(matlabtype, matlab, "Object.ComputeSomething()");
}
catch (Exception e)
{
}
}
to create an object of a particular class, set some properties and compute something. Here:
ComputeSomething();
returns a scalar.
I am just wondering whether this is the best way to program this and what’s the cleanest way to obtain the actual scalar value without using string operations (e.g. remove ans =)?
Thanks.
Christian