Excel Link    
MLGetMatrix

Write contents of MATLAB matrix in Excel worksheet

Syntax

Worksheet:
MLGetMatrix(var_name, edat)
Macro:
MLGetMatrix var_name, edat
var_name
Name of MATLAB matrix to access. "var_name" (in quotes) directly specifies the matrix name. var_name (without quotes) 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.
edat
Worksheet location where the function writes the contents of var_name. "edat" (in quotes) directly specifies the location and it must be a cell address or a range name. edat (without quotes) 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.

Description

Writes the contents of MATLAB matrix var_name in the Excel worksheet, beginning in the upper left cell specified by edat. If data already exists in the specified worksheet cells, it is overwritten. If the dimensions of the MATLAB matrix are larger than those of the specified cells, the data will overflow into additional rows and columns.

If edat is an explicit cell address and you later insert or delete rows or columns, or move or copy the function to another cell, edit edat to correct the address. Excel Link does not automatically adjust cell addresses in MLGetMatrix.

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, then press F9 to execute it. However, pressing F9 in this situation may also re-execute 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 Excel Link 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.

Examples

writes the contents of the MATLAB matrix bonds starting in cell C10 of Sheet2. If bonds is a 4-by-3 matrix, data fills cells C10..E13.

accesses the MATLAB matrix named as a string in worksheet cell B12 and writes the contents of the matrix in the worksheet starting at the location named as a string in worksheet cell B13.

writes the contents of MATLAB matrix A in the worksheet starting at the cell named RangeA.

See Also

MLAppendMatrix, MLPutMatrix


  MLEvalString MLGetVar