매틀랩(Matlab)에서 발생되는 여러 문제점과 답변
Why do my figures not stay open very long when using ActiveX with Visual Basic?
I am using ActiveX with Visual Basic. When I use the line indicated on page 5-9 of the API Guide (Result=Matlab.Execute("surf(peaks)")), the command is apparently executed but the figure (surf(peaks)) only appears a few seconds and then disappears.
The figure is disappearing because the MATLAB object variable is local to the Visual Basic subroutine (Dim MATLAB as Object). When the subroutine exits, Visual Basic cleans up the variable, including releasing the object (MATLAB) which is associated with the variable. If you want to have the connection remain active longer than the duration of the subroutine call, you need to make the variable global. We recommend that you read the Visual Basic manual for more information concerning creating global variables with Visual Basic and ActiveX.
MATLAB Runtime Server
Adapting the Design for Runtime Execution
Two aspects of this example make it suitable for runtime execution:
The way its front-end GUI design passes information among the user, the Visual Basic portion, and the MATLAB portion
The way its top-level M-file passes information between the Visual Basic portion and the rest of the MATLAB portion
This section describes each of these two aspects in turn.
The Front-End GUI
This example is a simple GUI-driven application that evaluates and plots a MATLAB expression. Its GUI is shown below.