Beruflich Dokumente
Kultur Dokumente
BASIC
1. In MatLab
, create a function that you want to deploy as a shared library. This example uses
the sample function called Nitrogen.m.
2.
3. In the Application Type section of the toolstrip, select .NET Assembly from the list.
The Library Compiler app adds Nitrogen.m to the list of files. The Library Compiler
app uses the name of the file as the name of the deployment project file (.prj),
shown in the title bar, and as the name of the assembly, shown in the first field of
the Application Information area. The project file saves all of the deployment
settings so that you can re-open the project.
5. In the Packaging Options section of the toolstrip, verify that the Runtime downloaded from web
check box is selected. This option creates an application installer that automatically downloads
the MATLAB Runtime and installs it along with the deployed add-in.
6. In the Class Name column of the class browser, replace Class1 with NitrogenClass.
7. Click Package.
The Package window opens while the library is being generated. Select the Open output folder
when process completes check box. The packaging process generates a self-extracting file that
automatically registers the DLL and unpacks all deployable deliverables.
8. When the deployment process is complete, a file explorer opens and displays the generated
output.
It should contain:
13. Add reference to your application. Click Project > Add Reference.
14. Create a reference to your assembly. The assembly is located in the application folder created
when you installed the component. For this example, select Nitrogen.dll.
16. Add a TextBox, Button and Label for the user interface in the window form designer. Change
the Text Property of Button by OK and Label by Result as shown in figure below.
17. Right click the window form designer and click view code or just simply click F7. Add the
following codes.
Imports Nitrogen
Imports MathWorks.MATLAB.NET.Arrays
Imports MathWorks.MATLAB.NET.Utility
Public Class Form1
Dim imageLocation As String
Dim compute As New NitrogenClass
Public matlabresult As MWArray
End Class
18. Double click the OK button and add the following codes.
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
Handles Button1.Click
imageLocation = TextBox1.Text.ToString
matlabresult = compute.Nitrogen(imageLocation)
Label1.Text = matlabresult.ToString
End Sub
19. The syntax of the application will be similar at the figure below.
20. After you finish writing your code, you build and run it.