c# & matlab

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Fabian Ruranski

    #1

    c# & matlab

    hi,

    i'm searching for a way to connect matlab from c#.

    im vb it is very easy:

    Set MatLab = CreateObject("M atlab.Applicati on")
    result = MatLab.execute( "a=5")


    but im c# ????


  • Erik Wikström

    #2
    Re: c# & matlab

    "Fabian Ruranski" <xplod@fcsnet.d e> wrote in message
    news:#nec53gaDH A.1488@TK2MSFTN GP12.phx.gbl...[color=blue]
    > hi,
    >
    > i'm searching for a way to connect matlab from c#.
    >
    > im vb it is very easy:
    >
    > Set MatLab = CreateObject("M atlab.Applicati on")
    > result = MatLab.execute( "a=5")
    >
    >
    > but im c# ????[/color]

    A quick search in the help-files gives me
    Object MyObject;
    MyObject = Server.CreateOb ject("Acme.Comp onent.3");

    Try searching for CreateObject and COM in the documentation for
    more detailed information.

    --
    Erik Wikström


    Comment

    • James F. Bellinger

      #3
      Re: c# &amp; matlab

      If it's available as a COM object or somesuch,
      VS.Net should be able to build you a wrapper.
      It's in Add Reference, one of the tabs at the top
      is COM References, IIRC...

      Have a nice day :)
      Jim Bellinger

      "Fabian Ruranski" <xplod@fcsnet.d e> wrote in message
      news:%23nec53ga DHA.1488@TK2MSF TNGP12.phx.gbl. ..[color=blue]
      > hi,
      >
      > i'm searching for a way to connect matlab from c#.
      >
      > im vb it is very easy:
      >
      > Set MatLab = CreateObject("M atlab.Applicati on")
      > result = MatLab.execute( "a=5")
      >
      >
      > but im c# ????
      >
      >[/color]


      Comment

      • Goran Genter

        #4
        Re: c# &amp; matlab

        "James F. Bellinger" <NaturesEtherea l@do.not.spam.m e> wrote in message
        news:ezBoqspaDH A.4028@tk2msftn gp13.phx.gbl[color=blue]
        > If it's available as a COM object or somesuch,
        > VS.Net should be able to build you a wrapper.
        > It's in Add Reference, one of the tabs at the top
        > is COM References, IIRC...
        >[/color]

        I've tryed following :
        I added reference to COM : "Matlab Application (Version 6.0) Type Library"
        and then wrote this :

        using MLApp;

        ..
        ..
        ..
        private void Form1_Load(obje ct sender, System.EventArg s e)
        {
        MLAppClass ml = new MLAppClass();
        ml.Execute("a=5 ");
        }

        First line opens Matlab Command Window.

        Second line couses exception :

        "An unhandled exception of type 'System.Invalid CastException' occurred in
        mscorlib.dll
        Additional information: QueryInterface for interface MLApp.DIMLApp failed."

        That example in VB that Fabian posted works fine. This one doesn't.
        Does anybody know why?


        Comment

        Working...