Main Content

matlabsub

EvaluateMATLABcommand givenMicrosoftExceldata and designate output location

Description

example

= matlabsub(command,result,inputs)specifies the MATLAB®command for evaluation in the MATLAB workspace, given the input datainputs. The function returns the MATLAB output into the worksheet cell specified byresult. Use this syntax when working in a worksheet cell.

Examples

collapse all

Enter the number four in cellA1.

Enter this text into cellA2. Specify the functionmagic的命令。返回佛urth-order magic square into the range of cells starting in cellA4. Reference cellA1as the input argument for themagicfunction.

=matlabsub("magic","A4",A1)

Worksheet cell A2 contains the entered text.

The fourth-order magic square displays in the range of cells fromA4throughD7.

Cell A2 contains 0, which indicates the successful execution of the magic function.

Enter the number four in cellA1. Enter a target cell reference to cellA6in cellA2.

Enter this text into cellA4. Specify the functionmagic的命令。返回佛urth-order magic square into the range of cells starting in cellA6by entering the cell referenceA2. Reference cellA1as the input argument for themagicfunction.

=matlabsub("magic",A2,A1)

工作表细胞A4包含输入文本。

The fourth-order magic square displays in the range of cells fromA6throughD9.

Cell A4 contains 0, which indicates the successful execution of the magic function.

Input Arguments

collapse all

MATLAB command to evaluate, specified as a string. Enclose the string in double quotes. Or, enter the string in a cell without quotes and enter the corresponding cell reference without quotes as the input argument.

Example:"sum"

Example:A1

MATLAB result, specified as an Excel cell reference or range name that designates the location where to display the result of the MATLAB command. To return the result in a specific cell, specify the cell reference enclosed in quotes. To denote a worksheet cell address or range name that contains a cell reference to another cell, specify the cell reference without quotes.

Example:"A3"

Example:D6

MATLAB command input arguments, specified as an Excel cell reference or a reference to a range of cells. To specify multiple input arguments for a function, separate the cell references with commas.

Example:B1:B10

Example:A1:C1,A3

Tips

  • To return an array of data to the Microsoft®Excel Visual Basic®for Applications (VBA) workspace, seeMLEvalStringandMLGetVar.

  • resultmust not include the cell that containsmatlabsub. Do not overwrite the function itself.

  • Ensure that there is enough room in the worksheet for writing matrix contents. If there is insufficient room, the function generates a fatal error.

  • Ifmatlabsubfails, a standard Spreadsheet Link™ error displays by default; for example,#COMMAND. To return MATLAB errors, useMLShowMatlabErrors.

Version History

Introduced before R2006a