|
-
Nov 12th, 2003, 10:05 AM
#1
Thread Starter
Lively Member
Matlab Instance
Is it possible to invoke an instance of Matlab, and run a piece of code using vb.net?
-
Nov 12th, 2003, 10:07 AM
#2
I wonder how many charact
Lookup the Process component.
VB Code:
Dim myProcess as New Process()
myProcess.StartInfo.FileName = "Notepad.exe"
myProcess.StartInfo.WindowStyle = ProcessWindowStyle.Maximized
myProcess.Start()
-
Nov 12th, 2003, 10:33 AM
#3
Thread Starter
Lively Member
I can add a reference to matlab so shouldnt i be able to reference it like an excel object, or any other reference?
using something like this
Dim objMatlab as new Matlab.Application
....
however matlab isnt showing up as an available keyword
i know i can do the process thing, but i want to run matlab from vb, by sending it command lines and having matlab execute them
any way to do this?
-
Nov 12th, 2003, 10:38 AM
#4
I wonder how many charact
Did you use
at top of your class or form?
-
Nov 12th, 2003, 10:44 AM
#5
Thread Starter
Lively Member
tried it, but it didnt like the Matlab, and it didnt show up as with the other importables like 'System', 'Microsoft', 'MLApp'...
-
Nov 12th, 2003, 10:46 AM
#6
Thread Starter
Lively Member
nevermind, i think MLApp is the matlab reference
-
Nov 12th, 2003, 11:38 AM
#7
Thread Starter
Lively Member
ok, so i can start an instance of MatLab, however, when i attempt to execute a piece of code i get the following
"QueryInterface for interface MLApp.DIMApp failed."
i looked it up on mathworks' webist and they have the following code, but its for VJ...
using System;
using System.Reflection;
namespace ConsoleApplication4
{
class Class1
{
[STAThread]
static void Main(string[] args)
{
//Get the type info
Type matlabtype;
matlabtype = Type.GetTypeFromProgID("matlab.application");
//Create an instance of MATLAB
object matlab;
matlab = Activator.CreateInstance(matlabtype);
//Prepare input as an object
object[] arrayInput = new Object[] {"surf(peaks)"};
//Call MATLAB method
matlabtype.InvokeMember("Execute",BindingFlags.InvokeMethod,null,matlab,arrayInput);
}
}
}
I can get everything going except the following
object[] arrayInput = new Object[] {"surf(peaks)"};
//Call MATLAB method
matlabtype.InvokeMember("Execute",BindingFlags.InvokeMethod,null,matlab,arrayInput);
the null part in the last line is whats giving me trouble, as well as the arrayInput. I dont know how to set a value to null in vb.net since you cant use System.DBNull in an expression, again, any help would be great
-
Nov 12th, 2003, 01:09 PM
#8
I wonder how many charact
I think you want to pass Nothing in place of Null.
-
Nov 12th, 2003, 01:24 PM
#9
I wonder how many charact
VB Code:
Dim ArrayInput() as Object = new Object(){"surf(peaks)"}
-
Mar 15th, 2006, 02:03 AM
#10
Junior Member
Re: Matlab Instance
 Originally Posted by nemaroller
I think you want to pass Nothing in place of Null.
nothing is for vb. null for c,java aand stuff like that
-
Mar 15th, 2006, 03:04 AM
#11
Re: Matlab Instance
 Originally Posted by midhat
nothing is for vb. null for c,java aand stuff like that
This thread is over two years old. I think everyone who posted to it is either dead or dribbling in an old folks home.
-
Mar 15th, 2006, 10:07 AM
#12
Junior Member
Re: Matlab Instance
lolz sorry. i am new and dint see the date on it. i know how it feels wen some1 does such stuff as i am also a mod somewhere else.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|