Encode

From Eigenvector Research Documentation Wiki
Revision as of 08:19, 2 September 2008 by imported>Jeremy (Importing text file)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

Purpose

Translates a variable into matlab-executable code.

Synopsis

str = encode(item,varname)
str = encode(item,varname,options)

Description

The created code can be eval'd or included in an m-file to reproduce the variable. This is essentially an inverse function of "eval" for variables. Input is a variable (item) and an optional name for that variable (varname). If (varname) is omitted, the input variable name will be used. If varname is empty, leading code which does assignment is omitted. Output is a string (str) which can be inserted into an m-file or passed to eval for execution.

Options

  • max_array_size : [10000] Maximum size allowed for any array dimension. Arrays with any size larger than this will be returned as simply [NaN]
  • structformat : [ 'struct' | {'dot'} ] defines how structures are encoded. 'struct' uses a "struct('a',val)" style (but can get very complex with large structures). 'dot' uses "x.a = val" format which is easier to read, but less compact.
  • forceoneline : [ {'off'} | 'on' ] remove all line breaks and ellipses from output. WARNING: this can cause a VERY long line on big objects and may exceed the maximum line length of editors or even MATLAB.

Example Create code to reproduce a preprocessing structure >> p = preprocess('default','meancenter'); >> encode(p)

See Also

encodexml, parsexml