Wednesday, March 24, 2010

Interface between MATLAB and VB.NET

To interface MATLAB and VB.NET a .dll file has to be created.

Steps to create a dll file

1) Open MATLAB  R2009a  software
2) Type deploytool in the MATLAB Command Window and press Enter key
3) A new Deployment Tool Window will be opened
4) Click on the New Deployment Project Icon (Circled in the figure below)




5) Select the MATLAB Builder NE option
6) Then Select Generic COM Component, enter a name of the project and press OK




7) A new deployment project will be created
8) Add the MATLAB .m files to the project by clicking on the icon circled below





9) Note that the .m files must be a function. For example, file Test2.m contains the function as follws:


Test2.m

function y = Test2(p)
y = imread(p); % reads image file
j = rgb2gray(y); % converts a colored image to grayscale image
imwrite(j,'C:\matlabtempimage.jpg','jpg'); % stores the image to a location in hard disk



10) More than one .m files can be added
11) Also other files such as C, C++ etc. can also be added
12) After adding all the desired files Click on Build Project icon (Circled in the image below)




13) A new dialog window Deployment Tool Output will open
14) For the first time only it will ask you to select a compiler for compiling the project
15) Click on the link in the new window opened and select a compiler form the list provided by entering the number next to the compiler and press Y to confirm
16) I would suggest select Visual C++ 2008 Compiler
17) After selecting the compiler the MATLAB program will start compiling the project. It will display Compilation completed successfully if there are no errors else it will display the errors. It takes some time so be patient.
18) After the compilation Click on the package button, circled in the figure below




19) After packaging a folder with the project name will be created in the MATLAB folder
20) The dll file is present in the src and distrib folder
21) The dll file has to be registered in order to use it in VB.NET

Two ways for registering the dll file:

Method 1

• Open DOS Command prompt
• Give the location of the dll file present in the src folder. For example:

C:\>cd C:\Documents and Settings\My Documents\MATLAB\Test\src

Then enter the command regsvr32 space (dll filename) For example:

C:\Documents and Settings\My Documents\MATLAB\Test\src>regsvr32 Test_1_0.dll

The following message will be displayed





Method 2

Double Click on the _install.bat file in the distrib folder. The dll file will be registered automatically



After registering the dll file, Open Microsoft Visual Basic 2008
• Open the your project and select Project --> Add Reference
• Select COM --> Select your dll file --> Click on OK
• The dll file will then be added as reference

Note that each time changes are made to the .m file the above process of building, packaging, registering and adding as reference must be repeated.


Example on How to call the dll file


Form1.vb

 
Public Class Form1
Private cal As Test.TestClass

....

....

Private Sub BackgroundWorker1_DoWork(ByVal sender As System.Object, ByVal e As System.ComponentModel.DoWorkEventArgs) Handles BackgroundWorker1.DoWork
Dim d, b As Object
cal = New Test.TestClass
d = Me.OpenFileDialog1.FileName
Call cal.Test2(1, b, d)
End Sub

....

End Class

Tuesday, January 5, 2010

LATEX - A tool for documentation

I was introduced to LATEX during a workshop held in our college.

LATEX is the most useful tool in preparing technical or non-technical documents. LATEX is a scripting language.

Technical documents mostly contain equations and symbols such as summation, integration, etc. which cannot be created in Word. In such cases LATEX is useful.

If any changes are made in a document created in Word, the alignment and the number of pages also change. Hence the user has to not only concentrate on the content but also on the format. This is very time consuming.

As LATEX is based on scripts which have a predefined format, the user has to only set the format once and can concentrate on the contents of the documentation. Any changes made to the document in future will automatically follow the pre-set format. This saves the users time.

While LATEX is very useful, the only challenge lies in learning the scripts. But once learned it can be helpful  in creating documents with ease.

LATEX is mainly used on Linux Operating System, but it is also available for Windows and MAC.

Further details on LATEX is avalable at 

http://www.pinteric.com/miktex.html

Monday, January 4, 2010

Beauty Of Art

Beauty Of Art is a small static website developed by me. This site shows the various forms of creativity in the form of pictures and videos.
This site is developed by using frames in HTML. There are three frames.
1) The top frame contains the banner
2) The left frame contains the links to various forms of art
3) The right frame shows the various forms of art

The source code is available for download. The home.htm file is the main page.

Download