Skip to Main Content Skip to Search
Product Documentation

MLPutVar - Create or overwrite MATLAB matrix with data from Microsoft Excel VBA variable

Syntax

MLPutVar ML_var_name, VBA_var_name
out = MLPutVar ML_var_name, VBA_var_name

Description

MLPutVar ML_var_name, VBA_var_name creates or overwrites matrix ML_var_name in MATLAB workspace with data in VBA_var_name. Creates ML_var_name if it does not exist. If ML_var_name exists, this function replaces the contents with data from VBA_var_name.

out = MLPutVar ML_var_name, VBA_var_name lets you catch errors when executing MLPutVar. If MLPutVar fails, then out is a string containing error code. Otherwise, out is 0.

Tips

Input Arguments

ML_var_name

Name of MATLAB matrix to create or overwrite.

ML_var_name in quotes directly specifies the matrix name. ML_var_name without quotes specifies a VBA variable that contains the matrix name as a string.

VBA_var_name

Name of VBA variable whose contents are written to ML_var_name.

Use VBA_var_name without quotes.

Output Arguments

out

0 if the command succeeded. Otherwise, a string containing error code.

Examples

Create a MATLAB Matrix Using Data Stored in a VBA Variable

Create (or overwrite) the MATLAB matrix K with the data in the VBA variable DataK:

Sub Put()
MLPutVar "K", DataK
End Sub

See Also

MLGetVar

  


Recommended Products

Includes the most popular MATLAB recorded presentations with Q&A sessions led by MATLAB experts.

 © 1984-2012- The MathWorks, Inc.    -   Site Help   -   Patents   -   Trademarks   -   Privacy Policy   -   Preventing Piracy   -   RSS