5.0

5.0 | 3 ratings Rate this file 28 Downloads (last 30 days) File Size: 8.91 KB File ID: #16549

Using C# functions and forms in Matlab

by Dirk-Jan Kroon

 

24 Sep 2007 (Updated 26 Sep 2007)

This script shows how C# functions/classes can be used in Matlab

| Watch this File

File Information
Description

This script shows how C# functions/classes and forms (gui) can be used in Matlab.

The zip contains:
- a example c# class (ComMatlab.cs) with different inputs and outputs functions.
- a info_ComMatlab.txt with the commands how to compile and register a c# activex control
- a ComMatlabtest.m for testing the c# functions.

- a example c# class (MatlabGUI.cs) which creates a form for user input (uses the other MatlabGUI cs files)
- a info_MatlabGUI.txt with the commands how to compile and register a c# activex control from multiple .cs files
- a MatlabGUItest.m for testing the c# userinput Form

(The MatlabGUI Form is designed with Visual Studio 2005)

Acknowledgements
This submission has inspired the following:
How to load / call functions from a VB DLL
MATLAB release MATLAB 7.5 (R2007b)
Other requirements .Net Framework version 2
Tags for This File  
Everyone's Tags
Tags I've Applied
Add New Tags Please login to tag files.
Comments and Ratings (5)
22 Dec 2008 Ofer Fridman

Best

20 Feb 2009 Francis  
20 Feb 2009 Francis

Dear Dirk-Jan Kroon,
Thanks for your post. Compiling is ok but when I try to use in Matlab, i got following error :
>> net = actxserver('MatlabGUI.FormControlClass');
??? Error using ==> feval
Server Creation Failed: Le fichier spécifié est introuvable.
If you could help, would be nice. Thanks
 

23 Feb 2009 Francis

Dear Dirk-Jan Kroon,
I found my pb, the code works fine now. The pb was that I did not subscribe to COM Interop in the project properties.
Thanks again for this very useful post.
Francis

30 Aug 2010 Eddie

I tried to configure MSVC to compile the dll (used File->New->Project->CisualC#->Class Library) and got the error

>> ComMatlabtest
??? Error using ==> actxserver at 91
Server creation failed. Invalid ProgID 'ComMatlab.ComMatlabClass'

Error in ==> ComMatlabtest at 7
net = actxserver('ComMatlab.ComMatlabClass'); % Load the ActiveX ComMatlab

I traced it down to a project properties setting under "Application" where you must select the "Assembly Information" button and then select the "Make assembly COM-Visible" checkbox.

Please login to add a comment or rating.
Updates
26 Sep 2007

Added C# code and matlab files for creation of a C# form for user input.

And also renamed files to more logical names

Tag Activity for this File
Tag Applied By Date/Time
external interface Dirk-Jan Kroon 22 Oct 2008 09:28:12
c Cristina McIntire 06 Feb 2009 11:20:36
dot Cristina McIntire 06 Feb 2009 11:20:36
net Cristina McIntire 06 Feb 2009 11:20:36
functions Cristina McIntire 06 Feb 2009 11:20:36
speed up Cristina McIntire 06 Feb 2009 11:20:36
communications Cristina McIntire 06 Feb 2009 11:20:36
fast Cristina McIntire 06 Feb 2009 11:20:36
activex Cristina McIntire 06 Feb 2009 11:20:36
activex cemil kaya 04 Nov 2010 11:51:16

Contact us at files@mathworks.com