| Spreadsheet Link™ EX | ![]() |
Worksheet: | MLGetMatrix(var_name, edat) |
Macro: | MLGetMatrix var_name, edat |
var_name | Name of MATLAB matrix to access."var_name" (in quotation marks) directly specifies the matrix name. var_name (without quotation marks) is an indirect reference: the function evaluates the contents of var_name to get the matrix name, and var_name must be a worksheet cell address or range name. var_name cannot be the MATLAB variable ans. |
edat | Worksheet location where the function writes the contents of var_name. "edat" (in quotation marks) directly specifies the location and it must be a cell address or a range name. edat (without quotation marks) is an indirect reference: the function evaluates the contents of edat to get the location, and edat must be a worksheet cell address or range name. |
Writes the contents of MATLAB matrix var_name in the Excel worksheet, beginning in the upper-left cell specified by edat. If data exists in the specified worksheet cells, it is overwritten. If the dimensions of the MATLAB matrix are larger than that of the specified cells, the data overflows into additional rows and columns.
Caution edat must not include the cell that contains the MLGetMatrix function. In other words, be careful not to overwrite the function itself. Also make sure there is enough room in the worksheet to write the matrix contents. If there is insufficient room, the function generates a fatal error. |
MLGetMatrix function does not automatically adjust cell addresses. If edat is an explicit cell address, edit it to correct the address when you do either of the following:
Insert or delete rows or columns.
Move or copy the function to another cell.
If worksheet calculation mode is automatic, MLGetMatrix executes when you enter the formula in a cell. If worksheet calculation mode is manual, enter the MLGetMatrix function in a cell, and then press F9 to execute it. However, pressing F9 in this situation may also reexecute other worksheet functions and generate unpredictable results.
If you use MLGetMatrix in a macro subroutine, enter MatlabRequest on the line after the MLGetMatrix. MatlabRequest initializes internal Spreadsheet Link™ EX variables and enables MLGetMatrix to function in a subroutine. Do not include MatlabRequest in a macro function unless the function is called from a subroutine.
Write the contents of the MATLAB matrix bonds starting in cell C10 of Sheet2. If bonds is a 4-by-3 matrix, fill cells C10..E13 with data:
MLGetMatrix("bonds", "Sheet2!C10")
Access the MATLAB matrix named by the string in worksheet cell B12. Write the contents of the matrix to the worksheet starting at the location named by the string in worksheet cell B13:
MLGetMatrix(B12, B13)
Write the contents of MATLAB matrix A to the worksheet, starting at the cell named by RangeA:
Sub Get_RangeA() MLGetMatrix "A", "RangeA" MatlabRequest End Sub
In a macro, use the Address property of the range object returned by the VBA Cells function to specify where to write the data:
Sub Get_Variable() MLGetMatrix "X", Cells(3, 2).Address MatlabRequest End Sub
![]() | MLGetFigure | MLGetVar | ![]() |
| © 1984-2008- The MathWorks, Inc. - Site Help - Patents - Trademarks - Privacy Policy - Preventing Piracy - RSS |