Databases Reference
In-Depth Information
ReturnMsg =
MatLab.Execute(frm9ShowMatrix.TextBox_Expression.Text)
'Add Results to Textbox Log
frm9ShowMatrix.TextBox_Results.Text =
frm9ShowMatrix.TextBox_Results.Text & ReturnMsg
End Sub
Notice that no error checking is done on the string to be executed; therefore, if it is invalid, an
error message will be returned by Matlab and printed to the results window. Also, the results written
to the results window can be cleared using the following code:
Private Sub Button_Clear_Click()
frm9ShowMatrix.TextBox_Results.Text = ""
End Sub
The results window is simply a textbox with the vertical scrollbars enabled (ScrollBars property
set to 2). The messages returned from Matlab are simply appended to the end of the existing text
within the textbox.
When the form is closed and the application is terminated, it is imperative to shut down the
Matlab server and release the reference.
Private Sub UserForm_Terminate()
'Quit and release the reference
MatLab.Quit
Set MatLab = Nothing
End Sub
Although the preceding example is somewhat rudimentary in nature, it sets the stage for building
more complex projects that perform more sophisticated analyses. With the ability to define matrices
and vectors at will, execute expressions upon those definitions, and return the results generated by
Matlab on the preceding actions, any calculations possible within Matlab can now be harnessed
by an Excel client.
9.5
USING MATLAB TO PERFORM MORE ADVANCED
FORMS OF REGRESSION
Building upon the methods discussed in the previous section, an application will be created to solve
a linear system of equations of the form
Ax = b,
where:
A =
matrix of known coefficients
x = a column vector of
n
×
n
n
unknowns
b = a column vector of
n
known coefficients
In this instance, the number of equations is equal to the number of unknowns. In such a case,
Ax = b
is said to be consistent and will possess a unique solution. For
Ax = b
to be consistent, the following
must be true:
1.
Ax = 0
has only the trivial solution x = 0.
2.
A
is nonsingular and its inverse exists.
3.
Rank A
= n.
4.
Det(A)
0.
5.
The Reduced Row Echelon Form (RREF) of
A
is the identity matrix.
6.
A
has
n
linearly independent rows and columns.
Search WWH ::




Custom Search