Encode: Difference between revisions
Jump to navigation
Jump to search
imported>Jeremy (Importing text file) |
imported>Jeremy (Importing text file) |
||
Line 9: | Line 9: | ||
Output is a string (str) which can be inserted into an m-file or passed to eval for execution. | Output is a string (str) which can be inserted into an m-file or passed to eval for execution. | ||
===Options=== | ===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] | * '''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. | * '''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. | * '''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''' | '''Example''' | ||
Create code to reproduce a preprocessing structure | Create code to reproduce a preprocessing structure |
Revision as of 19:56, 2 September 2008
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)