A New Mixing Programming Method

MATLAB, developed by Mathworks co., is a high-performance language for technical computing. It integrates computation, visualization, and programming in an easy-to-use environment where problems and solutions are expressed in familiar mathematical notation. Because of powerful matrix computation, it is called Matrix Lab. Matlab Language is similar with natural language. The usage of Matlab is extremely convenient. It also have plenty functions that can be called easy. But, it also has some shortcomings. Because the MATLAB language is a kind of explanation execution script language, it is very slow regarding the loops sentence execution. Under the same condition, compared to some high level languages such as Vc and VB, It executes loops sentences at the slow speed. The graphic user interface (GUI) of The MATLAB is not very friendly, and the parameter input and the output is not convenient. VB, as a kind of high level computer language, executes loops sentences more quickly, and its GUI is user-friendly. By incorporating visual programming interface of VB with the powerful function of MATLAB in numerical calculation and graphic display, we can take their advantages and avoid their weaknesses.


Introduction
MATLAB, developed by Mathworks co., is a high-performance language for technical computing.It integrates computation, visualization, and programming in an easy-to-use environment where problems and solutions are expressed in familiar mathematical notation.Because of powerful matrix computation, it is called Matrix Lab.Matlab Language is similar with natural language.The usage of Matlab is extremely convenient.It also have plenty functions that can be called easy.But, it also has some shortcomings.Because the MATLAB language is a kind of explanation execution script language, it is very slow regarding the loops sentence execution.Under the same condition, compared to some high level languages such as Vc and VB, It executes loops sentences at the slow speed.The graphic user interface (GUI) of The MATLAB is not very friendly, and the parameter input and the output is not convenient.VB, as a kind of high level computer language, executes loops sentences more quickly, and its GUI is user-friendly.By incorporating visual programming interface of VB with the powerful function of MATLAB in numerical calculation and graphic display, we can take their advantages and avoid their weaknesses.

Methodology
There are two methods to merging programming of Matlab and vb.

By some communication Technology between two different tools such as (Dynamic Data Exchange) DDE, Object Linking and embedding (OLE) automation and ActiveX controls. In this method, Matlab is taken as a object server and client can control Matlab by the associated methods of Matlab objects.
Among the above mentioned 2 methods, Among above mentioned 2 methods, the process of the first method is more complicated, require the operator higher computer level, and it is also time-consuming.
Compared to method one, the second is easy to carry out and have a lot of advantages.Therefore, in this paper, we mainly discuss method two.One interested in the other method can further read the reference.
MATLAB can not only be the automation controller, can also be the automation server.In order to realize the call the function of MATLAB, one can take Matlab as the automation server, naturally, VB as the automation controller.
Before calling one must at first know the name of the Matlab ActiveX objects in the system registry, namely, ProgID.Generally, the name is MATLAB.Application or MATLAB.Application.Single.
The former means to automate MATLAB the server be a share of server, other procedures can adjust to use; The former means that the Matlab automation server is a shared server and other program can call its service.While, the latter means that Matlab is taken as a exclusive server and, if other program need to call its service, a new Matlab automation server have to run.The concrete realizations of the hybrid programming is illustrated as the following, (1) Run the Matlab automation server In VB integrated development environment, the sentences to run Matlab automation server is as the following, Dim matlab as object Set Matlab=createobject("matlab.application") //Had better minimize the automation server after it run.

MATLAB. MinimiZeCommandWindow().
(2) Input and output of data In Matlab, there are two methods to input and output data, PutFullMatrix and GetFullMatrix.The definition of GetFullMatrix in Matlab is as the following, [3,4] void GetFullMatrix(

Function
) pi); This function can transfer one or two dimensional arrays in Matlab workspace into VB program.According to its definition, VB can call this function of Matlab.For example, one need to transfer matrix A in default Matlab workspace into a 4X4 matrix in VB.The definition of PutFullMatrix in Matlab follows, PutFullMatrix can transfer the arrays variables in VB into Matlab matrix.For instance, the following sentence will load complex number with real part called Mreal and imaginary part Mimage into matrix A in Matlab workspace.aninstance that demonstrates how to use these two functions as the following, CreateObject("matlab.application") Call MatLab.PutFullMatrix("A", "base", XReal, XImag) Call MatLab.GetFullMatrix("A", "base", ZReal, ZImag)(3)Execute the Matlab sentences.While the automation server is running, by calling the methods 'execute'of Matlab automation server, one can execute any sentences in Matlab.For instance, running the following codes in VB, x = 0:pi/100:8*pi;

Figure 1 .
Figure 1.The results(the left is the code and the right is the results.)