Databases Reference
In-Depth Information
endrow = LastRow(ActiveWorkbook.Name,
frm9ShowMatrix.ComboBox_Worksheets.Text)
Case False 'Determine Size from RefEdit
'Get the address, or reference, from the RefEdit control.
Addr = frm9ShowMatrix.RefEdit.Value
'Set the SelRange Range object to the range specified in
the RefEdit control.
Set CoeffMatrix = Range(Addr)
'Create "A" Matrix Based on Cell Values
CoeffRng = CoeffMatrix.Address(, , xlR1C1)
Call SetRefEditMatrixRanges(CoeffRng, startrow, startcol,
endrow, endcol)
End Select
SendMsg = CreateMatrix
(frm9ShowMatrix.TextBox_Array,
ActiveWorkbook.Name, _
frm9ShowMatrix.ComboBox_Worksheets.Text, startrow, startcol,
endrow, endcol, True, frm9ShowMatrix.OB_Space.Value)
'Debug.Print SendMsg
'If this Matrix or Vector Already Exists in Memory Clear it out!
MatLab.Execute ("clear " & frm9ShowMatrix.TextBox_Array & ";")
'Assign Matrix or Vector in Matlab
ReturnMsg = MatLab.Execute(SendMsg)
'Debug.Print ReturnMsg
frm9ShowMatrix.TextBox_Results.Text =
frm9ShowMatrix.TextBox_Results.Text & ReturnMsg
End Sub
Notice that the preceding subroutine accomplishes several things. It reestablishes its connection
to the Matlab server, defines the limits of the matrix, calls a function to create the matrix, clears
out the matrix should it already exist in Matlab's memory, writes the matrix to Matlab, and displays
any results returned by Matlab to Excel to the Results textbox. Notice that it is the
CreateMatrix
function that actually constructs the matrix passed to Matlab. The function has the following passed
parameters that determine how the elements that form the matrix will be assigned and written:
ID — a unique letter assignment for the matrix
wkbook — the Workbook the matrix data resides in
wksheet — the Worksheet the matrix data resides in
startrow — the starting row for the matrix data
startcol — the starting column for the matrix data
endrow — the ending row for the matrix data
endcol — the ending column for the matrix data
ReturnMsgs — return messages from Matlab to Excel (T/F)?
SpaceDelim — should spaces be utilized as the column delimiters (T/F)?
Function CreateMatrix(ID As String, wkbook, wksheet, startrow,
startcol, endrow, endcol, ReturnMsgs As Boolean, SpaceDelim
As Boolean) As String
Search WWH ::




Custom Search