I have a program that will be passing data to a C# script.
C# will then be modifying the data and I need it to be sent
to Matlab. Matlab will perform some function and then pass
the data back to C#. This all needs to be done in real
time, and not necessarily on the same computer. So how do
I pass data from C# to Matlab? I've been reading a lot of
help files in the Simulink and Real Time Workshop
categories, but I can't piece it all together to get a
useful answer. Most of my searches online have led to
people wanting to call C# from Matlab or convert their
Matlab files to C# or things like that. I want to have a
stand-alone Matlab file (probably a Simulink model) that
just sits there waiting for information, and have the
information coming from a separate C# program. Is this
doable and how?
"Daniel " <cowmaster6@yahoo.com> wrote in message
<fmleji$33i$1@fred.mathworks.com>...
> I have a program that will be passing data to a C#
script.
> C# will then be modifying the data and I need it to be
sent
> to Matlab. Matlab will perform some function and then
pass
> the data back to C#. This all needs to be done in real
> time, and not necessarily on the same computer. So how
do
> I pass data from C# to Matlab? I've been reading a lot
of
> help files in the Simulink and Real Time Workshop
> categories, but I can't piece it all together to get a
> useful answer. Most of my searches online have led to
> people wanting to call C# from Matlab or convert their
> Matlab files to C# or things like that. I want to have a
> stand-alone Matlab file (probably a Simulink model) that
> just sits there waiting for information, and have the
> information coming from a separate C# program. Is this
> doable and how?
Register your C# as COM library. Right click on your
project, go to Build and check the box "Register as Com
Interop". Then create an interface for the methods you want
to expose to COM and add the following attributes. A GUID
can be created in VS2005 (see Tools)
[Guid("xxxxxxxx-xxxx-xxxx-xxx-xxxxxxxxxxxx")]
[ComVisible(true)]
public interface IComInterface
{
char SeparationCharacter { get;}
bool LogOff(string userID);
}
Implement the interface on a class and set the following
attributes on this class
[ProgId("MyCom.1.0.0")]
[ClassInterface(ClassInterfaceType.None)]
[Guid("xxxxxxxx-xxxx-xxxx-xxx-xxxxxxxxxxxx")]
[ComVisible(true)]
public class ComClass: IComInterface
{
public char SeparationCharacter
{
get
{
return '#';
}
}
public bool LogOff(string userID);
{
return true;
}
}
Create an instance of this class using actxserver:
Public Submission Policy
NOTICE: Any content you submit to MATLAB Central, including personal information, is not subject to the protections which may be afforded information collected under other sections of The MathWorks, Inc. Web site. You are entirely responsible for
all content that you upload, post, e-mail, transmit or otherwise make available via MATLAB Central. The MathWorks does not control the content posted by visitors to MATLAB Central and, does not guarantee the accuracy, integrity, or quality of such content.
Under no circumstances will The MathWorks be liable in any way for any content not authored by The MathWorks, or any loss or damage of any kind incurred as a result of the use of any content posted, e-mailed, transmitted or otherwise made available
via MATLAB Central. Read the complete Disclaimer prior to use.