Main Content

matlabfcn

EvaluateMATLAB命令给MicrosoftExceldata

Description

example

= matlabfcn(command,inputs)specifies the MATLAB®command for evaluation in the MATLAB workspace, given the input datainputs. Depending upon the MATLAB output,matlabfcnreturns a single value or string into the calling worksheet cell. If the result contains more than one value in MATLAB, only the first value in the array returns in the calling worksheet cell. Use this syntax when working in a worksheet cell.

Examples

collapse all

Usingstd, find the maximum likelihood estimate of the standard deviation of data in worksheet cellsA1throughA10. Assume that the data comes from a normal population. Specify a weight of one in cellC1. Return the result by entering this text into cellA12.

=matlabfcn("std",A1:A10,C1)

Worksheet cells A1 through A10 contain the input data, cell C1 contains the weight, and cell A12 contains the entered text.

CellA12displays the maximum likelihood estimate of the standard deviation.

Worksheet cell A12 contains the result of executing the std 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 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

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

  • 执行一个马TLAB command that returns no data, use theMLEvalStringfunction instead ofmatlabfcn. In this case, write a command such asMLEvalString("function(" & A1 & ")"), wherefunctionis the name of the function that returns no data andA1is an input argument.

Version History

Introduced before R2006a