Main Content

MLDeleteMatrix

删除MATLABmatrix

Description

example

= MLDeleteMatrix(var_name)deletes the named matrix from the MATLAB®Workspace.Use this syntax when working directly in a worksheet.

example

MLDeleteMatrixvar_namedeletes the named matrix from the MATLAB Workspace.Use this syntax in a VBA macro.

out= MLDeleteMatrix(var_name)lets you find errors when executingMLDeleteMatrixin a VBA macro. IfMLDeleteMatrixfails, thenoutis a string containing an error code. Otherwise,outis0.

Examples

collapse all

删除a matrix in the MATLAB Workspace using theMLDeleteMatrixfunction in an Excel®worksheet.

Create a 2-by-2 MATLAB matrixA.

A = [2 3; 4 6];

Open Excel and make sure cellA1is selected in the worksheet. Delete the matrixAusing theMLDeleteMatrixfunction. Enter this text in the cell and pressEnter.

= MLDeleteMatrix("A")

TheMLDeleteMatrixfunction deletes the matrix from the MATLAB Workspace.

删除a matrix in the MATLAB Workspace using theMLDeleteMatrixfunction in a VBA macro.

Create a 2-by-2 MATLAB matrixA.

A = [2 3; 4 6];

On theDevelopertab in Excel, clickVisual Basicin theCodegroup. The Visual Basic®Editor window opens.

SelectInsert>Moduleto insert a new module. In the Module1 window, enter this VBA code containing a macro named删除Matrix.

Sub DeleteMatrix() MLDeleteMatrix "A" End Sub

The删除Matrixmacro uses theMLDeleteMatrixfunction to delete the matrixAfrom the MATLAB Workspace.

For details about working with modules, see Excel Help.

Run the macro by clickingRun Sub/UserFormbutton on the VBA toolbar. For details about running macros, see Excel Help.

TheMLDeleteMatrixfunction deletes the matrix from the MATLAB Workspace.

Input Arguments

collapse all

MATLAB垫的名称rix to delete, specified as a string.

var_namein quotes directly specifies the matrix name.var_namewithout quotes specifies a worksheet cell address (or range name) that contains the matrix name.

Example:"A"

Tips

  • To work with VBA code in Excel with Spreadsheet Link™, you must enable Spreadsheet Link as a reference in theMicrosoft®Visual BasicEditor. For details, seeInstallation.

Version History

Introduced before R2006a