Main Content


(Not recommended) Save optimization variable description


writevar is not recommended. Use write instead.

writevar(var) saves a description of the optimization variable in a file named variable.txt. Here, variable is the Name property of var. The writevar function overwrites any existing file.


writevar(var,filename) saves a description of the optimization variable in a file named filename.


collapse all

Create an optimization variable and save its description in a file.

var = optimvar('var',8,3,'Type','integer');

The contents of VariableDescription.txt:

    [ var(1, 1)     var(1, 2)     var(1, 3) ]    
    [ var(2, 1)     var(2, 2)     var(2, 3) ]    
    [ var(3, 1)     var(3, 2)     var(3, 3) ]    
    [ var(4, 1)     var(4, 2)     var(4, 3) ]    
    [ var(5, 1)     var(5, 2)     var(5, 3) ]    
    [ var(6, 1)     var(6, 2)     var(6, 3) ]    
    [ var(7, 1)     var(7, 2)     var(7, 3) ]    
    [ var(8, 1)     var(8, 2)     var(8, 3) ]    

Input Arguments

collapse all

Optimization variable, specified as an OptimizationVariable object. Create var using optimvar.

Example: var = optimvar('var',4,6)

Path to the file, specified as a string or character vector. The path is relative to the current folder. The resulting file is a text file, so the file name typically has the extension .txt.

Example: "../Notes/steel_stuff.txt"

Data Types: char | string

Version History

Introduced in R2017b

expand all

Not recommended starting in R2019b