Home
LyME User Manual
Contents
1. 0 000002 29 3 2 Function Call 0 0000000000000 e 30 33 Libr esj eaae eb ae Bee aol eB doe ee Ele 32 34 WV DCEShicica de Ge kw als pow eae car Apa we Boe aa eee 32 3 5 Input and Output 0 000005 40 3 6 ErrorMessages 0 0000 e eee eee 41 3 7 Variable Assignment and Subscripting 46 3 8 Programming Constructs 0200005 53 3 9 Debugging Commands 00 000 as 69 3 10 Miscellaneous Functions 76 ere ee ee eee ee ee EE 101 3 12 OPEKalOKrs eee ok we oe le ee ee a Be ee Be 103 3 13 Mathematical Functions 135 LyME User Manual 1999 2008 Calerga Sarl bled aaa n kab E hb Eee eo we 188 3 15 Array Functions 000000 eee ee 233 3 16 Triangulation Functions 004 267 3 17 Integer Functions 0 0 000002 ee eee 274 3 18 Non Linear Numerical Functions 277 3 19 String Functions 00000002 ee eee 294 3 20 List FUNCTIONS lt nc Shee Pk oO ede awe a 308 3 21 Structure Functions 0 0 0000 ee eee 312 3 22 Object Functions 00 0000 2 eee 319 3 23 Logical Functions 0000000 eee 321 3 24 Dynamical System Functions 333 3 25 Input Output Functions 2 005 340 3 26 Palm Database Functions 0005 356 3 27 Palm File Streaming Function
2. msin Complete elliptic integrals of first and second kinds with phi pi 2 can be obtained with ellipke See also ellipj Jacobi elliptic functions Syntax sn cn dn sn cn dn ellipj u m ellipj u m tol LME Reference mathematical functions 153 Description ellipj u m gives the Jacobi elliptic function sn cn and dn Parame ter m must be in 0 1 These functions are based on the Jacobi elliptic amplitude 9 the inverse of the Jacobi elliptic integral of the first kind which can be obtained with ellipam u F g m sn u m sin cn u m cos dn u m 1 m sin 9 ellipj u m tol uses tolerance tol the default tolerance is eps Examples sn cn dn ellipj 2 7 0 6 sn 0 8773 cn 4799 i il dn 0 7336 Sin ellipam 2 7 0 6 0 8773 ellipj 0 5 0 3 0 0000 0 8188 0 9713 0 4114 0 5341 0 9930 See also ellipke Complete elliptic integral Syntax K E ellipke m K E ellipke m tol 154 LyME User Manual 1999 2008 Calerga Sarl Description K E ellipke m gives the complete elliptic integrals of the first kind K F m and second kind E E m defined as 1 2 dt m 0 y1l msin t T 2 Em V1 msin tdt 0 Parameter m must be in 0 1 ellipke m tol uses tolerance tol the default tolerance is eps Example K K E ellipke 0 3 1 7139 E 1 4454 See also eps Difference between 1 and the smallest n
3. Syntax char A char sl s2 5 S Description char A converts the elements of matrix A to characters resulting in a string of the same size Characters are stored in unsigned 16 bit words The shape of A is preserved Even if most functions ignore the string shape you can force a row vector with char A char s1 s2 concatenates vertically the arrays given as ar guments to produce a string matrix If the strings do not have the same number of columns blanks are added to the right Examples char 65 70 ABCDEF char 65 66 67 68 ABCD char ab cde ab cde char abc de fg abc de fg See also deblank Remove trailing blank characters from a string Syntax s2 deblank s1 LME Reference strings 297 Description deblank s1 removes the trailing blank characters from string s1 Blank characters are spaces code 32 tabulators code 9 carriage returns code 13 line feeds code 10 and null characters code 0 Example double tAB CD r n 0 32 9 65 66 32 32 67 68 13 10 0 double deblank tAB CD n r 0 32 9 65 66 32 32 67 68 See also findstr Find a substring in a string Syntax pos findstr str sub Description findstr str sub finds occurrences of string sub in string str and returns a vector of the positions of all occurrences or the empty vector if there is none Occurrences may overlap Examp
4. Conversion single decimal number as an integer same as d hexadecimal number for integers between 0 and 2732 1 same as x with uppercase digits octal number for integers between 0 and 2732 1 fixed number of decimals exp notation if abs x gt 1e18 same as f with an uppercase E scientific notation such as 1e5 scientific notation such as 1E5 engineering notation such as 100e3 engineering notation such as 100E3 decimal or scientific notation same as g with an uppercase E same as g with as few characters as possible same as k with an uppercase E character string NOARX OC ZS mo naO XXE gQ The flag forces octal numbers to begin with 0 nonzero hexadec imal numbers to begin with 0x and floating point numbers to always have a decimal point even if they do not have a fractional part Instead of decimal digits the width n and or the precision d can be replaced with character x then one or two additional arguments or elements of an array are consumed and used as the width or preci sion LME Reference input output 353 Examples sprintf d 2f 2e 2E 2g pixones 1 5 3 3 14 3 14e0 3 14E0 3 14 sprintf 1k 0 001 0 11 111 1000 le 3 0 11 111 1e3 sprintf 8 3f 8 65 8 6s pi abcdefgh abcdefgh 3 142 abcdef xabcdef sprintf c_ a z a_b_c_d_e_f_g_h_i_j_k_l_m_n_o_p_q_r_s_t_u_v_w_x_y_z sprintf f 15 7 pi 3 1415927 sprintf 3d
5. Description polyval pol x evaluates the polynomial pol at x which can be a scalar or a matrix of arbitrary size The result has the same size as x Examples polyval 1 3 8 2 18 polyval 1 2 1 5 34567 See also prod Product of the elements of a vector 224 LyME User Manual 1999 2008 Calerga Sarl Syntax x prod v v prod M v prod M dim Description prod v returns the product of the elements of vector v returns a row vector whose elements are the products of the corre sponding columns of matrix M prod M dim returns the product of matrix M along dimension dim the result is a row vector if dim is 1 or a column vector if dim is 2 Examples prod 1 5 120 prod 1 5 120 prod 1 2 3 5 6 7 5 12 21 prod 1 2 3 5 6 7 1 5 12 21 prod 1 2 3 5 6 7 2 6 210 See also qr QR decomposition Syntax Q R E qr A Q R qr A Qe Re e qr A false Qe Re qr A false LME Reference linear algebra 225 Description With three output arguments qr A computes the QR decomposition of matrix A with column pivoting i e a square unitary matrix Q and an upper triangular matrix R such that A E Q R With two output argu ments qr A computes the QR decomposition without pivoting such that A QxR With a second input argument with the value false if A has m rows and n columns with m gt n qr produces an m by n Q and an n by n R Bottom rows of zeros of R and
6. abcdefg ab abcd 3 See also LME Reference strings 305 strtok Token search in string Syntax token remainder token remainder strtok str strtok str separators Description strtok str gives the first token in string str A token is defined as a substring delimited by separators or by the beginning or end of the string by default separators are spaces tabulators carriage returns and line feeds If no token is found i e if str is empty or contains only separator characters the result is the empty string The optional second output is set to what follows immediately the token including separators If no token is found it is the same as str An optional second input argument contains the separators in a string Examples Strings are displayed with quotes to show clearly the separators strtok ab cde ab t r strtok ab cde t tat r cde t r strtok 2 5 3 t Fa r 5 37 See also strtrim Remove leading and trailing blank characters from a string 306 LyME User Manual 1999 2008 Calerga Sarl Syntax s2 strtrim s1 Description strtrim s1 removes the leading and trailing blank characters from string s1 Blank characters are spaces code 32 tabulators code 9 carriage returns code 13 line feeds code 10 and null characters code 0 Example double tAB CD r n 0 32 9 65 66 32 32 67 68 13 10
7. bbb de b z bc aa bbb c ia setdiff a b C a de ia 14 a ia a de See also setxor Set exclusive or Syntax c setxor a b c ia ib setxor a b LME Reference arrays 259 Description setxor a b performs an exclusive or operation between sets a and b i e it gives the set of members of sets a and b which are not mem bers of the intersection of a and b Sets are any type of numerical character or logical arrays or lists or cell arrays of character strings Multiple elements of input arguments are considered as single mem bers the result is always sorted and has unique elements The optional second and third output arguments are vectors of indices such that if c ia ib setxor a b then c is the union of a ia and b ib Example a a bc bbb de b z bc aa bbb c ia ib setxor a b c a aa de z ia 14 ib 31 union a ia b ib a aa de z Set exclusive or can also be computed as the union of a and b minus the intersection of a and b setdiff union a b intersect a b a aa de z See also setdiff size Size of an array Syntax v size A m n size A m size A i 260 LyME User Manual 1999 2008 Calerga Sarl Description size A returns the number of rows a
8. dog cat weight 3 100 3 18 ee Hl cell2struct dog cat 3 100 3 18 name weight C 1 1 name dog C 1 1 weight 3 100 C 1 2 name cat C 1 2 weight 3 18 Value sequences Value sequences are usually written as values separated with com mas They are used as function input arguments or row elements in arrays or lists When expressions involving lists cell arrays or structure arrays evaluate to multiple values these values are considered as a value sequence or part of a value sequence and used as such in context where value sequences are expected The number of values can be known only at execution time and may be zero L v c 1 2 L convert L to a row vector complex L convert L to a complex number Value sequences can arise from element access of list or cell arrays with brace indexing or from structure arrays with field access with or without parenthesis indexing Function references Function references are equivalent to the name of a function together with the context in which they are created Their main use is as argu ment to other functions They are obtained with operator Inline and anonymous functions Inline and anonymous functions encapsulate executable code They differ only in the way they are created inline functions are made with function inline while anonymous functions have special syntax
9. function global if otherwise persistent private public repeat return switch try until use useifexists while See also lasterr Last error message 92 LyME User Manual 1999 2008 Calerga Sarl Syntax msg lasterr msg identifier lasterr Description lasterr returns a string which describes the last error With two out put arguments it also gives the error identifier It can be used in the catch part of the try construct Example Index out of range msg identifier lasterr msg Index out of range identifier LME indexOutOfRange See also lasterror try error lasterror Last error structure Syntax s lasterror Description lasterror returns a structure which describes the last error It con tains the following fields identifier string short tag which identifies the error message string error message The structure can be used as argument to rethrow in the catch part of a try catch construct to propagate the error further LME Reference miscellaneous functions 93 Example xXx 2 x 3 Index out of range lasterror message Index out of range identifier LME indexOutOfRange See also nargin Number of input arguments Syntax n n nargin nargin fun Description Calling a function with less arguments than what the function expects is permitted In this case
10. Description fopen path opens the file specified by string path on the first vol ume in read only mode The argument contains either the full path of the file on the first volume or the volume name and the full path separated with a colon e g card dir file txt fopen path mode opens a file in read only mode if mode is r or in read write mode if mode is w mode can have a second character which is ignored for compatibility with other versions of fopen LME Reference VFS 365 Example fd fopen Data Measures data txt w for i l size data 1 fprintf g t data i fprintf n end fclose fd See also vfsdelete Delete a file or an empty directory Syntax vfsdelete volume path Description vfsdelete volume path deletes a file or an empty directory whose absolute path is path on volume volume Both arguments are strings See also vfsdir Get the list of files and directories Syntax vfsdir volume vfsdir volume directorypath list vfsdir 366 LyME User Manual 1999 2008 Calerga Sarl Description vfsdir volume displays the list of files and directories at the root level of volume volume Hidden files are not displayed Directories are followed with a slash read only files with ro system files with s and links with U vfsdir volume directorypath displays the list of files and di rectories in the d
11. c2dm 1 1 1 5 t numd 0 7143 0 7143 dend 1 0 4286 numc denc d2cm numd dend numc 3 8858e 17 1 denc 11 See also dmargin Robustness margins of a discrete time system Syntax gm psi wc wx gm psi wc Wwx dmargin num den Ts dmargin num den Description The open loop discrete time transfer function is given by the two poly nomials num and den with sampling period Ts default value is 1 If the closed loop system with negative feedback is unstable all out put arguments are set to an empty matrix Otherwise dmargin calcu lates the gain margins gm which give the interval of gain for which the closed loop system remains stable the phase margin psi al ways positive if it exists which defines the symmetric range of phases which can be added to the open loop system while keeping the closed loop system stable the critical frequency associated to the gain mar gins where the open loop frequency response intersects the real axis around 1 and the cross over frequency associated to the phase mar gin where the open loop frequency response has a unit magnitude If the Nyquist diagram does not cross the unit circle psi and wx are empty Examples Stable closed loop Nyquist inside unit circle LME Reference dynamical systems 337 gm psi wc wx dmargin 0 005 poly 0 9 0 9 gm 2 38 psi wc 0 0 4510 wx Stable closed loop Nyquist crosses unit cir
12. dbnewrec dbName Description dbnewrec dbName adds a new record to the database identified by its name dbName It returns a file descriptor which should be saved and used with functions such as fprintf and fwrite Once the record is written fclose should be called to terminate the record creation The second output argument if present is set to the index of the record The first record has index 0 Example Creation of a new note for the Memo Pad application Note that the record ends with a null byte fd dbnewrec MemoDB fprintf fd Sine between 0 and 90 deg n for a 0 15 90 fprintf fd sin d g n a sin a end fwrite fd 0 fclose fd See also dbnumrec Number of records in a database Syntax n dbnumrec dbName LME Reference Palm database 361 Description dbnumrec dbName gives the number of records in the database iden tified by its name dbName See also dbopenrec Open an existing database record Syntax fd fd dbopenrec dbName index dbopenrec dbName index mode Description dbopenrec dbName index opens a record from the database identi fied by its name dbName in read only mode The record itself is iden tified by its index the first record has index 0 dbopenrec returns a file descriptor which should be saved and used with functions such as fgets fscanf and fread Once the record has been read fclose should be called A third input argum
13. dbstep dbstep in dbstep out Description When normal execution is suspended after a breakpoint set with dbstop or the execution of function dbhalt dbstep issued from the command line executes the next line of the suspended function If the line is the last one of the function execution resumes in the calling function dbstep in has the same effect as dbstep except if a subfunction is called In this case execution is suspended at the beginning of the subfunction dbstep out resumes execution in the current function and sus pends it in the calling function LME Reference debugging commands 73 Example Load library stdlib and put a breakpoint at the beginning of function Linspace use stdlib dbstop linspace Start execution of function Linspace until the breakpoint is reached the next line to be executed is displayed v Llinspace 1 2 5 lt linspace 8 gt if nargin lt 3 When the execution is suspended any function can be called Local variables of the function can be accessed and changed but no new variable can be created Here the list of variables and the value of x2 are displayed info v r not defined x1 1x1 x2 1x1 n 1x1 x2 x2 2 Display the stack of function calls dbstack stdlib linspace 8 Execute next line dbstep lt linspace 11 gt r xl x2 x1 x O n 1 n 1 Execute last line then normal execution is resumed dbstep y 1 1 25 1 5 1 75 2 Display br
14. fminbnd fun xlow xhigh x y fminbnd options x y fminbnd options x y didConverge fminbnd Description fminbnd fun finds numerically a local minimum of function fun fun is either specified by its name or given as an anonymous or inline function or a function reference It has at least one input argument x and it returns one output argument also a real number fminbnd finds the value x such that fun x is minimized Second argument tells where to search it can be either a starting point or a pair of values which must bracket the minimum The optional third argument may contain options It is either the empty array for default options or the result of optimset Remaining input arguments of fminbnd if any are given as addi tional input arguments to function fun They permit to parameterize the function For example fminbnd fun x0 2 5 calls fun as fun x 2 5 and minimizes its value with respect to x 278 LyME User Manual 1999 2008 Calerga Sarl The first output argument of fminbnd is the value of x at optimum The second output argument if it exists is the value of fun x at op timum The third output argument if it exists is set to true if fminbnd has converged to an optimum or to false if it has not in that case other output arguments are set to the best value obtained With one or two output arguments fminbnd throws an error if it does not con verge Examples
15. nan 1 1 2 6 nan LME Reference mathematical functions 159 See also fix Rounding towards 0 Syntax y f1ix x Description fix x truncates the fractional part of x If the argument is a complex number the real and imaginary parts are handled separately Examples fix 2 3 2 Tix 2 6 2 See also Floor ceil round floor Rounding towards infinity Syntax y floor x Description floor x gives the largest integer smaller than or equal to x If the argument is a complex number the real and imaginary parts are han dled separately 160 LyME User Manual 1999 2008 Calerga Sarl Examples floor 2 3 2 floor 2 3 3 See also gamma Gamma function Syntax y gamma x Description gamma x gives the gamma function of x Argument and result are real imaginary part is discarded The gamma function is defined as 0 0 r x Pte at 0 For positive integer values n n 1 Examples gamma 5 24 gamma 3 inf gamma 3 5 0 2701 See also gammainc Incomplete gamma function LME Reference mathematical functions 161 Syntax y gammainc x a Description gammainc x a gives the incomplete gamma function of x and a Ar guments and result are real imaginary part is discarded x must be nonnegative The incomplete gamma function is defined as 1 x gammainc x a tet dt r a Jo Example gammainc 2 1 5 0 7385 See
16. unsigned long fun const void emulStateP void datain Call68KFuncType call68KFuncP Please refer to Palm OS documentation at http www palmos com for more informations Warning pcenativecalLl has the potential of crashing LyME if its arguments do not correspond to valid code and data See also Dinarydata processorname peek Get a word anywhere in memory Syntax value peek address Description peek address reads a short word two bytes of memory at the ad dress specified which must be even Several words may be read in one command if the argument is a vector or a matrix Machine code 407 See also poke Store a word anywhere in memory Syntax poke address value Description poke address value stores a short word two bytes of memory at the address specified which must be even Several words may be stored in one command if the arguments are vectors or matrices The size both arguments must be the same or the second argument value must be a scalar See also peek processorname Get the name of the microprocessor Syntax shortname processorname shortname fullname processorname Description processorname gets the name of the microprocessor of the hand held The first output argument is the short name such as 68328 or ARM720T the second output argument if it exists is the full name such as Motorola 68328 Dragonball or ARM 720T Chapte
17. 1 0 3 false FTFT See also pitemp Operator amp And Syntax b1 amp b2 and bl b2 Description b1 amp b2 performs the logical AND operation between the corresponding elements of b1 and b2 the result is true logical 1 if both operands are different from false or 0 and false logical 0 otherwise and b1 b2 is equivalent to b1 amp b2 It can be used to redefine this operator for objects Example false false true true amp false true false true FFFT See also operator amp amp Operator amp And with lazy evaluation Syntax bl amp amp b2 LME Reference operators 129 Description b1 amp amp b2 is b1 if b1 is false and b2 otherwise Like with if and while statements b1 is true if it is a nonempty array with only non zero elements b2 is evaluated only if b1 is true b1 amp amp b2 amp amp amp amp bn returns the last operand which is false remain ing Operands are not evaluated or the last one Example Boolean value which is true if the vector v is made of pairs of equal values mod length v 2 0 amp amp v 1 2 end v 2 2 end The second operand of amp amp is evaluated only if the length is even See also Operator Or Syntax b1 b2 or b1 b2 Description b1 b2 performs the logical OR operation between the corresponding elements of b1 and b2 the result is false logical 0 if both operands are false or 0 and true logical 1 othe
18. 3d 12 12345 012 12345 Caveat Exotic formats unsupported See also fprintf sscanf sread Raw input from a string or an array of bytes Syntax a count sread str size precision a count sread str precision a count sread bytes Description sread str reads data from string str or array of class uint8 or int8 the same way as fread reads data from a file Examples data count sread abc data 354 LyME User Manual 1999 2008 Calerga Sarl data count sread abcdef 2 2 data 97 98 99 100 count 4 data count sread abcd inf 3 data 97 98 99 count 3 See also fread sscanf Decoding of formatted numbers Syntax r sscanf str format r count scanf str r format count nchar scanf str format Description Numbers characters and strings are extracted from the first argu ment Exactly what is extracted is controlled by the second argument which can contain the following elements Substring in format Orr OK anNO X X X X LM LP LM LM XE Q other character Meaning single character string integer number in decimal unsigned integer number in hexadecimal unsigned integer number in octal integer number floating point number floating point number floating point number exact match i recognizes an optional sign followed by a decimal number an hexadecimal number pre
19. Description corrcoef X calculates the correlation coefficients of the columns of the m by n matrix X The result is a square n by n matrix whose diag onal is 1 corrcoef X1 X2 calculates the correlation coefficients of X1 and X2 and returns a 2 by 2 matrix It is equivalent to corrcoef X1 X2 414 LyME User Manual 1999 2008 Calerga Sarl Example use stdlib corrcoef 1 3 2 5 4 4 7 10 1 0 8915 0 8915 1 corrcoef 1 5 5 1 1 1 1 1 1 See also COV cumtrapz Cumulative numerical integration with trapezoidal approximation Syntax use stdlib S cumtrapz Y S cumtrapz X Y S cumtrapz X Y dim Description cumtrapz Y calculates an approximation of the cumulative integral of a function given by the samples in Y with unit intervals The trape zoidal approximation is used If Y is neither a row nor a column vector integration is performed along its columns The result has the same size as Y The first value s is are 0 cumtrapz X Y specifies the location of the samples A third argu ment may be used to specify along which dimension the integration is performed Example use stdlib cumtrapz 2 3 5 0 2 5 6 5 cumtrapz 1 2 5 2 3 5 0 2 5 14 5 See also Libraries stdlib 415 fftshift Shift DC frequency of FFT from beginning to center of spectrum Syntax use stdlib Y fftshift X Description fftshift X shifts halves of vector 1 d or matrix 2 d X t
20. Description nichols a plots the Nichols diagram of system a See also lti nyquist lti bodemag lti bodephase Iti nyquist Nyquist plot Syntax use lti nyquist a nyquist a Description nyquist a plots the Nyquist diagram of system a See also ti nichols lt1i bodemag lt1i bodephase Iti step Step response Syntax use lti step a step a Description step a plots the step response of system a See also lti impulse Uti initial 490 LyME User Manual 1999 2008 Calerga Sarl 4 8 sigenc Sigenc is a library which adds to LME functions for encoding and de coding scalar signals It implements quantization DPCM differential pulse code modulation and companders used in telephony The following statement makes available functions defined in sigenc use sigenc alawcompress A law compressor Syntax use sigenc output alawcompress input output alawcompress input a Description alawcompress input a compresses signal input with A law method using parameter a The signal is assumed to be in 1 1 values out side this range are clipped input can be a real array of any size and dimension The default value of a is 87 6 The compressor and its inverse the expander are static nonlin ear filters used to improve the signal noise ratio of quantized signals The compressor should be used before quantization or on a signal represented with
21. Minimum of a sine near 2 displayed with 15 digits fprintf 15g n fminbnd sin 2 4 712389014989218 To find the minimum of ce sinx between 1 and 10 with c 0 1 the expression is written as an inline function stored in variable fun fun inline c exp x sin x Then fminbnd is used with the value of c passed as an additional argument xX fminbnd fun 1 10 0 1 x 1 2239 With an anonymous function this becomes c 0 1 fun x cxexp x sin x x fminbnd fun 1 10 x 1 2239 Attempt to find the minimum of an unbounded function x y didConverge fminbnd exp 10 x inf y 0 didConverge false See also LME Reference non linear numerical functions 279 fminsearch Minimum of a function in R n Syntax x fminsearch fun x0 x fminsearch options x fminsearch options x y didConverge fminsearch Description fminsearch fun x0 finds numerically a local minimum of func tion fun fun is either specified by its name or given as an anonymous or inline function or a function reference It has at least one input argument x a real scalar vector or array and it returns one output argument a scalar real number fminsearch finds the value x such that fun x is minimized starting from point x0 The optional third input argument may contain options It is either the empty array for default options or the result
22. Purpose first subscript array concatenation last subscript flip array flip left right flip upside down dimension inverse permutation test for empty array length of vector number of dimensions number of elements dimension permutation array replication array reshaping array rotation array size remove singleton dimensions Finally functions below are related to output and assignment Function disp dumpvar subsasgn subsref Purpose display conversion to string assignment to subarrays or to quaternion parts reference to subarrays or to quaternion parts Function imag is replaced with qimag which gives a quaternion with the real part set to zero because there are three imaginary compo nents instead of one with complex numbers Operators and functions which accept multiple arguments convert automatically double arrays to quaternions ignoring the imaginary part of complex numbers Conversion to numeric arrays with double adds a dimension for the real part and the three imaginary parts For example converting a scalar quaternion gives a 4 by 1 double column vector and converting a 2 by 2 quaternion array gives a 2 by 2 by 4 double array Real and Quaternions 375 imaginary components can be accessed with the field access notation q wis the real part of q q x q y and q z are its imaginary parts and q v is its imaginary parts as an array similar to the result of double but without the real part Compatib
23. See also cal2julian 3 31 Quaternions Quaternion functions support scalar and arrays of quaternions Basic arithmetic operators and functions are overloaded to support expres sions with the same syntax as for numbers and matrices Quaternions are numbers similar to complex numbers but with four components instead of two The unit imaginary parts are named i j and k A quaternion can be written w ix jy kz The following relationships hold 2 j k ijk 1 It follows that the product of two quaternions is not commutative for instance ij k but ji k Quaternions are convenient to represent arbitrary rotations in the 3d space They are more compact than matrices and are easier to normalize This makes them suitable to simulation and control of me chanical systems and vehicles such as flight simulators and robotics Functions below are specific to quaternions Function Purpose isquaternion test for quaternion type q2mat conversion to rotation matrix q2rpy conversion to attitude angles q2str conversion to string qimag imaginary parts qinv element wise inverse qnorm scalar norm qslerp spherical linear interpolation quaternion quaternion creation rpy2q conversion from attitude angles Operators below accept quaternions as arguments Quaternions Function ctranspose eq horzcat ldivide ne minus mldivide mrdivide mtimes plus rdivide times transpose uminus uplus vertcat 373 Operator Purpo
24. See also quantiz Table based signal quantization Syntax use sigenc i quantiz input partition i output distortion quantiz input partition codebook Description quantiz input partition quantizes signal input using partition as boundaries between different ranges Range from o to partition 1 corresponds to code 0 range from partition 1 to partition 2 corresponds to code 1 and so on input may be a real array of any size and dimension partition must be a sorted vector The output i is an array of codes with the same size and dimension as input quantiz input partition codebook uses codebook as a look up table to convert back from codes to signal It should be a vector with one more element than partition With a second output argu ment quantiz gives codebook i With a third output argument quantiz computes the distortion be tween input and codebook i i e the mean of the squared error Libraries sigenc 495 Example use sigenc partition 1 0 1 codebook 2 0 5 0 5 2 in randn 1 5 in 0 1799 9 7676e 2 1 1431 0 4986 1 0445 i out dist quantiz in partition codebook l1 2 1 0 1 2 out 0 5 0 5 2 0 5 0 5 dist 0 259 See also Lloyds dpcmenco ulawcompress mu law compressor Syntax use sigenc output ulawcompress input output ulawcompress input mu Description ulawcompress input a compresses signal input with mu law method us
25. bc bbb de d a x de a z m b ismember m s on ul oll 4m il TF TF See also length Length of a vector or a list Syntax n n length v length list Description length v gives the length of vector v length A gives the num ber of elements along the largest dimension of array A length list gives the number of elements in a list Examples length 1 5 eae amore ee 1 6 abc Length tO 248 LyME User Manual 1999 2008 Calerga Sarl See also magic Magic square Syntax M magic n Description A magic square is a square array of size n by n which contains each integer between 1 and n and whose sum of each column and of each line is equal magic n returns magic square of size n by n There is no 2 by 2 magic square If the size is 2 the matrix 1 3 4 2 is returned instead Example magic 3 816 357 4 2 our See also meshgrid Arrays of X Y coordinates Syntax X Y meshgrid x y X Y meshgrid x LME Reference arrays 249 Description meshgrid x y produces two arrays of x and y coordinates suitable for the evaluation of a function of two variables The input argument x is copied to the rows of the first output argument and the input argument y is copied to the columns of the second output argument so that both arrays have the same size meshgrid x is equivalent to meshgrid x x Examp
26. fun strl fun str1 fun strl str2 fun stri str2 fun abc def fun abc def Arguments can also be quoted strings in that case they may con tain spaces tabulators commas semicolons and escape sequences 32 LyME User Manual 1999 2008 Calerga Sarl beginning with a backslash see below for a description of the string data type Quoted and unquoted arguments can be mixed fun a bc n fun a bc n fun str1 str 2 fun stril1 str 2 This command syntax is especially useful for functions which accept well known options represented as strings such as format loose 3 3 Libraries Libraries are collections of user functions identified in LME by a name Typically they are stored in a file whose name is the library name with a Iml suffix for instance library stdlib is stored in file stdlib Iml Before a user function can be called its library must be loaded with the use statement use statements have an effect only in the context where they are placed i e in a library or the command line interface or a Sysquake SQ file this way different libraries may define functions with the same name provided they are not used in the same context In a library functions can be public or private Public functions may be called from any context which use the library while private functions are visible only from the library they are defined in 3 4 Types Numerical logical and ch
27. gt fd 1 redirect sprintf Formatted conversion of objects into a string Syntax s sprintf format a b Description sprintf converts its arguments to a string The first parameter is the format string All the characters are copied verbatim to the out put string except for the control sequences which all begin with the character They have the form fn dt 352 LyME User Manual 1999 2008 Calerga Sarl where f is zero one or more of the following flags Flag Meaning left alignment default is right alignment display of a sign for positive numbers 0 zero padding instead of spaces alternate format see below space sign replaced with space for positive numbers n is the optional width of the field as one or more decimal digits default is the minimum width to display the data d is the number of digits after the decimal separator for a number displayed with a fractional part the minimum number of displayed digits for a number displayed as an integer or the number of characters for a string one or more decimal digits by default it is 4 for a number or the length of the string for a string and t is a single character denoting the type of conversion In most cases each control sequence corresponds to an additional argument All elements of arrays are used sequentially as if they were provided separately strings are used as a whole The table below gives the valid values of t oO gt g
28. ode45 ode45 ode45 ode45 Description ode23 fun tQ tend y0 and ode45 fun t0 tend yO integrate numerically an ordinary differential equation ODE Both functions are based on a Runge Kutta algorithm with adaptive time step ode23 is low order and ode45 high order In most cases for non stiff equations ode45 is the best method The function to be integrated is either spec ified by its name or given as an anonymous or inline function or a function reference It should have at least two input arguments and exactly one output argument function yp f t y The function calculates the derivative yp of the state vector y at time t Integration is performed over the time range specified by the sec ond argument t0 tend starting from the initial state y0 It may stop before reaching tend if the integration step cannot be reduced enough to obtain the required tolerance If the function is continuous you can try to reduce MinStep in the options argument see below The optional fourth argument may contain options It is either the empty array for the default options or the result of odeset the use of a vector of option values is deprecated Events generated by options Events or EventTime can be obtained by three additional output arguments t y te ye ie returns event times in te the corresponding states in ye and the correspond ing event identifiers in ie Additional input arguments of ode45 are give
29. reshape 1 2 3 10 20 30 3 2 1 2 3 10 20 30 reshape 1 12 3 12 3 4 LME Reference arrays See also operator rot90 Array rotation Syntax A2 rot90 A1 A2 rot90 Al k Description 257 rot90 A1 rotates array Al 90 degrees counter clockwise the top left element of Al becomes the bottom left element of A2 If Al is an array with more than two dimensions each plane corresponding to the first two dimensions is rotated In rot90 A1 k the second argument is the number of times the array is rotated 90 degrees counter clockwise With k 2 the array is rotated by 180 degrees with k 3 ork 1 the array is rotated by 90 degrees clockwise Examples rot90 1 2 3 4 5 6 rot90 1 2 3 4 5 6 1 rot90 1 2 3 4 5 6 1 65 4 W See also fliplr flipud 258 LyME User Manual 1999 2008 Calerga Sarl setdiff Set difference Syntax c setdiff a b c ia setdiff a b Description setdiff a b gives the difference between sets a and b i e the set of members of set a which do not belong to b Sets are any type of nu merical character or logical arrays or lists or cell arrays of character strings Multiple elements of input arguments are considered as single members the result is always sorted and has unique elements The optional second output argument is a vector of indices such that if c ia setdiff a b then c is a ia Example a a bc
30. true islist true islist false ischar false 310 LyME User Manual 1999 2008 Calerga Sarl See also isstruct isnumeric ischar islogical isempty list2num Conversion from list to numeric array Syntax A List2num list Description List2num list takes the elements of List which must be numbers or arrays and concatenates them on a row along second dimension as if they were placed inside brackets and separated with commas Element sizes must be compatible Example List2num 1 2 3j 4 6 1 2 3j 4 5 6 See also operator T map Function evaluation for each element of a list Syntax listoutl map fun listinl Description map fun listinl evaluates function fun successively for each corresponding elements of the remaining arguments which must be lists or cell arrays It returns the result s of the evaluation as list s or cell array s with the same size as inputs Input lists which contain a single element are repeated to match other arguments if necessary fun is the name of a function as a string a function reference or an inline function LME Reference lists 311 Examples map max 2 6 4 7 1 1 100 6 7 100 map inline x 10 3 7 16 13 17 26 nr nc map size 1 abc 4 7 3 4 nr 1 1 2 nc 1 3 2 map size 1 abc 4 7 3 4 S 1 1 1 3 2 2 map disp hello l
31. 2 d Delaunay triangulation Syntax t delaunay x y t e delaunay x y 268 LyME User Manual 1999 2008 Calerga Sarl Description delaunay x y calculates the Delaunay triangulation of 2 d points given by arrays x and y Both arrays must have the same number of values m The result is an array of three columns Each row corre sponds to a triangle values are indices in x and y The second output argument if requested is a logical vector of size m by 1 elements are true if the corresponding point in x and y belongs to the convex hull of the set of points The Delaunay triangulation is a net of triangles which link all the starting points in such a way that no point is included in the circum scribed circle of any other triangle Triangles are as equilateral as possible Example Delaunay triangulation of 20 random points x rand 20 1 rand 20 1 y t e delaunay x y With Sysquake graphical functions points belonging to the convex hull are displayed as crosses and interior points as circles clf scale equal plot x e y e f plot x e y e 0 Array of vertex indices is modified to have closed triangles Triangles are displayed plot x t y t See also delaunayn N d Delaunay triangulation LME Reference triangulation 269 Syntax t delaunayn x t e delaunayn x Description delaunayn x calculates the Delaunay triangulation of points given by the
32. Calerga Sarl quaternion Quaternion creation Syntax quaternion quaternion w quaternion c quaternion x y Z quaternion w X y Z quaternion w v P EE o E o eo tod tw E E Description With a real argument quaternion x creates a quaternion object whose real part is w and imaginary parts are 0 With a complex argument quaternion c creates the quaternion object real c iximag c With four real arguments quaternion w x y z creates the quaternion object w i x j y k z With three real arguments quaternion x y z creates the pure quaternion object i x j y k z In all these cases the arguments may be scalars or arrays of the same size With two arguments quaternion w v creates a quaternion object whose real part is w and imaginary parts is array v v must have one more dimension than w for the three imaginary parts Without argument quaternion returns the zero quaternion object The real or imaginary parts of a quaternion can be accessed with field access such aS q w g X q y q Z and q v Examples q quaternion 1 2 3 4 q 1 2i 3j 4k q 5 6 214 3j 4k q q 28 41 6j 8k q 2 2 q 5 x2 quaternion array 0 quaternion 1 5 3 7 I AW lt N Il Quaternions 381 q 1 5i 3j 7k NWwWuc See also rpy2q Conversion from attitude angles to quaternion Syntax q rpy2q pitch roll yaw Description rpy2q pitch roll yaw gives the quaternion corresponding to a r
33. Convert a bitfield object to a double number Syntax use bitfield n double a Description double a converts bitfield a to double number Example use bitfield a bitfield 123 16 double a 123 See also bitfield end Last bit position in a bitfield 452 LyME User Manual 1999 2008 Calerga Sarl Syntax use bitfield a end Description In the index expression of a bitfield end is the position of the most significant bit i e 1 less than the word length See also bitfield bitfield bitfield beginning bitfield find Find the ones in a bitfield Syntax use bitfield ix find a Description find a finds the bits equal to 1 in bitfield a The result is a vector of bit positions in ascending order the least significant bit is number 0 Example use bitfield a bitfield 123 16 a 0b0000000001111011 ix find a ix 013456 See also bitfield int8 bitfield int16 bitfield int32 Convert a bitfield object to a signed integer number with sign exten sion Libraries bitfield 453 Syntax use bitfield n int8 a n int16 a n int32 a Description int8 a int16 a and int32 a convert bitfield a to an int8 int16 or int32 number respectively If a has less bits than the target integer and the most significant bit of a is 1 sign extension is performed i e the most significant bits of the result are set to 1 so that it is negative If a ha
34. Its main purpose is to permit to define large libraries in multiple files in a transparent way for the user include statements must not follow other statements on the same line and can reference only one library which is searched at the same locations as use They can be used only in libraries Since LME replaces include with the contents of lib one should be cautious about the public or private context which is preserved between the libraries It is possible to include a fragment of function without a function header See also includeifexists Include library if it exists Syntax includeifexists lib Description includeifexists lib inserts the contents of the library file Lib if it exists if the library does not exists it does nothing See also 62 LyME User Manual 1999 2008 Calerga Sarl otherwise Conditional execution of statements depending on a number or a string See also private Mark the beginning of a sequence of private function definitions in a library Syntax private Description In a library functions which are defined after the private keyword are private private may not be placed in the same line of source code as any other command comments are possible though In a library functions are either public or private Private functions can only be called from the same library while public functions can also be called from contexts where the library has been imported with a use command F
35. Operator lt Less or equal to Syntax Description x lt y is true if x is less than or equal to y and false otherwise Comparing NaN not a number to any number yields false including to NaN If x and or y is an array the comparison is performed element wise and the result has the same size le x y is equivalent to x lt y It can be used to redefine this op erator for objects Example 2 3 4 lt 2 4 2 TTF See also operator operator operator lt operator gt operator gt LME Reference operators 127 Operator gt Greater or equal to Syntax Description x gt y is true if x is greater than or equal to y and false otherwise Comparing NaN not a number to any number yields false including to NaN If x and or y is an array the comparison is performed element wise and the result has the same size ge x y is equivalent to x gt y It can be used to redefine this op erator for objects Example 2 3 4 gt 2 4 2 TFT See also operator operator operator lt operator lt operator gt Operator Not Syntax b not b Description b is false logical 0 if b is different from 0 or false and true otherwise If b is an array the operation is performed on each element not b is equivalent to b It can be used to redefine this operator for objects 128 LyME User Manual 1999 2008 Calerga Sarl Examples true false
36. The following statement makes available functions defined in ratio use ratio ratio ratio Ratio object constructor Syntax use ratio r ratio r ratio n r ratio num den r ratio r Description ratio num den creates a rational fraction object whose value is num den Arguments num and den may be double integer numbers or longint Common factors are canceled out With one numeric input argument ratio n creates a rational fraction whose denominator is 1 Without input argument ratio creates a rational number whose value is 0 With one input argument which is already a ratio object ratio returns it without change Libraries ratio 447 The following operators and functions may be used with ratio ob jects with results analog to the corresponding functions of LME eq mldivide gt ge mpower gt gt mrdivide inv mtimes lt le ne lt lt plus max uminus min uplus minus Examples use ratio r ratio 2 3 r 2 3 q 5 r 1 q 7 3 See also ratio disp ratio double ratio char ratio char Display a ratio object Syntax use ratio char r Description char r converts ratio r to a character string See also ratio disp 448 LyME User Manual 1999 2008 Calerga Sarl ratio disp Display a ratio object Syntax use ratio disp r Description disp r displays ratio r with the same format as char It is also ex ecuted implicitly when LME
37. and a column 1 2 3 4 5 6 a a 2 3 Extracting a sub array with contiguous rows and non contiguous columns a 1 2 1 3 1 2 1 3 46 Array elements as a vector Selections of elements where a logical expression is true 108 LyME User Manual 1999 2008 Calerga Sarl a a gt 5 5 6 a sum a l gt 6 23 5 6 Assignment a 1 5 99 a 23099 5600 REI Extraction and assignment of elements in a list a 1 2 7 3 abc magic 3 x a 2 5 2 7 3 x a 2 5 ab cde a 1 ab abc 8 1 6 3 5 7 4 9 2 cde a 2 5 3 9 a 1 3 9 abc 8 1 6 3 5 7 4 9 2 3 9 Removing elements in a list and have the same effect here a 4 a 1 3 9 abc 3 9 a 1 3 a 3 9 3 9 Replacing NaN with empty arrays in a cell array C abc nan 2 false C cellfun x any isnan x C Element in a structure array SA structarray a 1 2 3 b ab cde SA 1 a 23 SA 2 b X When assigning a new field and or a new element of a structure array the new field is added to each element and the size of the array is expanded fields are initialized to the empty array SA 3 c SA 1 c true LME Reference operators 109 See also Operator lend variable assignment ial Operator Brackets Syntax matr
38. assert Check that an assertion is true LME Reference miscellaneous functions 77 Syntax assert expr assert expr str assert expr format argl arg2 assert expr identifier format argl arg2 Description assert expr checks that expr is true and throws an error otherwise Expression expr is considered to be true if it is a non empty array whose elements are all non zero With more input arguments assert checks that expr is true and throws the error specified by remaining arguments otherwise These arguments are the same as those expected by function error When the intermediate code is optimized assert can be ignored It should be used only to produce errors at an early stage or as a de bugging aid not to trigger the try catch mechanism The expression should not have side effects The most common use of assert is to check the validity of input arguments Example function y fact n assert length n 1 amp amp isreal n amp amp n round n LME nonIntArg y prod 1 n See also error warning Ery builtin Built in function evaluation Syntax argoutl builtin fun arginl Description y1l y2 builtin fun x1 x2 evaluates the built in func tion fun with input arguments x1 x2 etc Output arguments are as signed to yl y2 etc Function fun is specified by its name as a String builtin is useful to execute a built in function which has been re defi
39. den butter n w0 butter n wl wh butter n w0 high butter n wl wh stop butter s Description butter calculates a Butterworth filter The result is given as zeros poles and gain if there are three output arguments or as numera tor and denominator coefficient vectors if there are two output argu ments butter n w0 where w0 is a scalar gives a nth order digital low pass filter with a cutoff frequency of w0 relatively to half the sampling frequency butter n wl wh where the second input argument is a vector of two numbers gives a 2nth order digital bandpass filter with pass band between wl and wh relatively to half the sampling frequency Libraries filter 459 butter n w0 high gives a nth order digital highpass filter with a cutoff frequency of w0 relatively to half the sampling frequency butter n wl wh stop where the second input argument is a vector of two numbers gives a 2nth order digital bandstop filter with stopband between wl and wh relatively to half the sampling frequency With an additional input argument which is the string s butter gives an analog Butterworth filter Frequencies are given in rad s See also cheblap Chebyshev type 1 analog filter prototype Syntax use filter z p k cheblap n rp Description cheblap n rp calculates the zeros the poles and the gain of a Chebyshev type 1 analo
40. for a ball which bounces between several walls the inter section between each wall and the ball trajectory would be a different event stream For events which occur at regular times EventTime is an n by two matrix for each row the first column gives the time step ts and the second column gives the offset to Non repeating events are specified with an infinite time step ts Events occur at time t to k ts where k is an integer When event time is varying EventTime is a function which can be defined as function eventTime eventtimefun t y 286 LyME User Manual 1999 2008 Calerga Sarl where t is the current time y the current state and the ellipsis stand for additional arguments passed to odex The function returns a col umn vector whose elements are the times where the next event oc curs In both cases each row corresponds to a different event stream For events which are based on the state the value of a function which depends on the time and the states is checked the event occurs when its sign changes Events is a function which can be defined as function value isterminal direction eventsfun t y Input arguments are the same as for EventTime Output arguments are column vectors where each element i corresponds to an event stream An event occurs when value i crosses zero in either direction if direction i 0 from negative to nonnegative if direction i gt 0 or from positive to nonpositive if di
41. inmem 90 int16 274 405 int32 274 405 int64 274 ints 274 405 Index interpl interpn intersect 244 intmax 275 intmin 275 inv 209 ipermute 245 isa TL Dag iscell ischar 298 isdigit isempty isfield isfinite 166 isfloat isglobal 90 isinf isinteger iskeyword isletter islist 309 is logical 330 ismember isnan 168 isnumeric 169 isobject 320 Torino REST isquaternion 375 isreal 417 isscalar 170 isspace 299 isstruct 314 isvector 171 join 309 julian2cal kron 209 kurtosis 210 lasterr lasterror Lem 171 ldivide 105 le 105 Length 247 405 507 library constants 501 date 498 filter 455 lti 465 ratio 446 Soe eT stat 426 stdlib 410 wav 496 linprog Linspace 418 list 36 List2num 310 lloyds LME command syntax comments 30 error messages file descriptor 40 function call input output libraries program format statements types variable assignment 46 Logspace 419 LongInt longint Lower 300 lu lyap 508 mad 429 magic map B10 map2int 2 76 margin 337 matrixco matrixro max 214 md5 mean 215 median 419 meshgrid methods 321 min 216 minus L05 mldivide 105 mod 174 moment 217 mpower 105 mrdivide mtimes 105 l w A U1 HIO nan 174 nancorrcoef nancov 430
42. n 7 8 if nargin lt 3 9 n 100 10 end gt 11 r x1 x2 x1 O n 1 n 1 See also echo Echo of code before its execution Syntax echo on echo off echo fun on echo state echo state fd echo fun state echo fun state fd ee a Description echo on enables the display of an echo of each line of function code before execution The display includes the function name and the line 76 LyME User Manual 1999 2008 Calerga Sarl number echo off disables the echo The argument can also be passed as a boolean value with the func tional form echo state echo on is equivalent to echo true echo fun on enables echo for function named fun only echo fun off disables echo the function name is ignored echo off has the same effect By default the echo is output to the standard error channel file descriptor 2 Another file descriptor can be specified as an additional numeric argument with the functional form only Example Trace of a function use stdlib echo on C compan 2 5 4 compan 26 if min size v gt 1 compan 29 v v 75 compan 30 n length v compan 31 M v 2 end v 1 eye n 2 n 1 Echo stored into a file log txt fd fopen log txt w echo true fd echo off fclose fd See also dbtype 3 10 Miscellaneous Functions This section describes functions related to programming function ar guments error processing evaluation memory
43. nanmean nanmedian 431 nanstd 432 nansum 433 nargin nargout 94 nchoosek ndgrid ndims 250 ne 105 nnz 250 norm 218 not 105 nthroot 176 null 218 num2cell num2List 311 number numel object LyME User Manual 1999 2008 Calerga Sarl ode23 282 ode45 odeset 284 ones 252 operator amp 128 NI TEES Q Z286 of Hf NINI oh oA lon Sete E rar ee ee a r n HHl HIN COL RILINILO oO m m m i xo l Doto oA A Vv Ayer Dorm S YI Lola OI NINIRINIRINIRTR HLS ro NO vlla NL eS ea oa oy N tO N optim or 10 orderfields 315 orth otherwise et Un pause 394 pcenativecall 406 polyder polyfit polyint processorname prod public quantiz 494 quaternion Quaternions rand 253 randn 254 range ioe rdivide 105 real 178 509 reallog realmax realmin realpow realsqrt redirect 350 rem T80 rmfield 316 roots 22 rot90 25 round 18 rpy2q 381 NJI Hl NI o sandbox 101 sandboxt rust 103 schur 227 sec 182 sech 183 selectday 397 selecttime 398 semilogx semilogy serialdevname 383 se aopen a serialdevset 384 set B9 setdiff 258 setfield setstr 301 setxor 258 sha1 302 sign Sin 183 Sinc 183 single eee Size 259 skewness 228 sort 260 sortrows 423 510 squareform 435 squee
44. not as a general purpose display func tion With more arguments warning uses the first argument as a format string and displays remaining arguments accordingly like fprintf Example warning Doesn t converge See also disp fprintf which Library where a function is defined Syntax fullname which name LME Reference sandbox function 101 Description which name returns an indication of where function name is defined If name is a user function or a method prefixed with its class and two colons the result is name prefixed with the library name and a slash If name is a built in function it is prefixed with builtin If itis a variable it is prefixed with var If name is neither a function nor a variable which returns the empty string Examples which lLogspace stdlib logspace which polynom plus classes polynom plus which sin builtin sin x 2 which x var x See also info 3 11 Sandbox Function sandbox Execute untrusted code in a secure environment Syntax sandbox str sandbox str varin varout sandbox str varout sandbox str varin Description sandbox str executes the statements in string str Functions which might do harm if used improperly are disabled they include those related to the file system to devices and to the network Global and persistent variables are forbidden as well but local variables can be created The same restrictions apply to funct
45. obsv a gives the observability matrix of system a which is full rank if and only if a is observable See also ss ctrb 480 LyME User Manual 1999 2008 Calerga Sarl Iti parallel Parallel connection Syntax use lti c parallel a b c parallel a b ina inb outa outb Description parallel a b connects lti objects a and b in such a way that the inputs of the result is applied to both a and b and the outputs of the result is their sum parallel a b ina inb outa outb specifies which inputs are shared between a and b and which outputs are summed The inputs of the result are partitioned as ua uab ub and the outputs as ya yab yb Inputs uab are fed to inputs ina of a and inb of b inputs ua are fed to the remaining inputs of a and ub to the remaining inputs of b Similarly outputs yab are the sum of outputs outa of a and outputs outb of b and ya and yb are the remaining outputs of a and b respectively See also Lti series Iti plus System sum Syntax use lti c at b c plus a b Description a b computes the system whose inputs are fed to both a and b and whose outputs are the sum of the outputs of a and b If a and b are transfer functions or matrices of transfer functions this is equivalent to a sum of matrices Libraries lti 481 See also Lti parallel lti minus Iti series Series connection Syntax use lti c series a b C series a b outa inb Descrip
46. pol2cart circshift Shift the elements of a matrix in a circular way Syntax use stdlib B circshift A shift_vert B circshift A shift_vert shift_hor 412 Description LyME User Manual 1999 2008 Calerga Sarl circshift A sv shifts the rows of matrix A downward by sv rows The sv bottom rows of the input matrix become the sv top rows of the output matrix sv may be negative to go the other way around circshift A sv sh shifts the rows of matrix A downward by sv rows and its columns to the right by sh columns The sv bottom rows of the input matrix become the sv top rows of the output matrix and the sh rightmost columns become the sh leftmost columns See also Tliptr flipud blkdiag Block diagonal matrix Syntax use stdlib X blkdiag Bl B2 Description blkdiag B1 B2 creates a block diagonal matrix with matrix blocks B1 B2 etc Its input arguments do not need to be square Example use stdlib blkdiag 1 2 3 4 5 blkdiag 1 2 3 4 See also diag Libraries stdlib 413 compan Companion matrix Syntax use stdlib X compan pol Description compan pol gives the companion matrix of polynomial pol a square matrix whose eigenvalues are the roots of pol Example use stdlib compan 2 3 4 5 1 5 2 0 2 5 1 0 0 0 0 0 0 0 1 0 0 0 See also corrcoef Correlation coefficients Syntax use stdlib S corrcoef X S corrcoef X1 X2
47. polynom 3 0 1 4 2 p 3x 4 x 2 4x 2 q 3 p2 8 27X 8 18x 6 72x 5 39x 4 24x 3 60x 2 48x 20 See also polynom disp polynom diff jratfun ratfun polynom double polynom int polynom inline polynom subst polynom feval polynom disp Display a polynom object Syntax use classes disp a Description disp a displays polynomial a It is also executed implicitly when LME displays the polynom result of an expression which does not end with a semicolon Example use classes p polynom 3 0 1 4 2 3x 4 x 2 4x 2 See also polynom polynom polynom double Convert a polynom object to a vector of coefficients Libraries classes 439 Syntax use classes coef double a Description double a converts polynomial a to a row vector of descending power coefficients Example use classes p polynom 3 0 1 4 2 double p 301 42 See also polynom polynom polynom subst Substitute the variable of a polynom object with another polynomial Syntax use classes subst a b Description subst a b substitutes the variable of polynom a with polynom b Example use classes p polynom 1 2 3 p X 24 3x 9 q polynom 2 0 2x r subst p q 4x 2 6x 9 440 LyME User Manual 1999 2008 Calerga Sarl See also polynom polynom polynom feval polynom diff Polynom derivative Syntax use classes d
48. returns a single boolean even if its operands are arrays unsame a b is equivalent to a b Example 1 5 1 5 false 1 5 1 5 FFFFF 1 2 3 4 5 true 1 2 3 4 5 Incompatible size nan nan false nan nan true LME Reference operators 125 See also operator lt operator lt oper Operator lt Less than Syntax x lt y lt x y Description x lt y is true if x is less than y and false otherwise Comparing NaN not anumber to any number yields false including to NaN If x and or y is an array the comparison is performed element wise and the result has the same size 1t x y is equivalent to x lt y It can be used to redefine this oper ator for objects Example 2 3 4 lt 2 4 2 FTF See also operator operator operator lt operator gt operator gt Operator gt Greater than Syntax x gt y gt x y 126 LyME User Manual 1999 2008 Calerga Sarl Description x gt y is true if x is greater than y and false otherwise Comparing NaN not a number to any number yields false including to NaN If x and or y is an array the comparison is performed element wise and the result has the same size gt x y is equivalent to x gt y It can be used to redefine this oper ator for objects Example 2 3 4 gt 2 4 2 FFT See also operator operator operator lt operator lt operator gt
49. sd a 99 1345 99 See also operator I operator O Operator dot Structure field access 112 LyME User Manual 1999 2008 Calerga Sarl Syntax v field v field expr Description A dot is used to access a field in a structure In v field v is the name of a variable which contains a structure and field is the name of the field In expressions v field gives the value of the field it is an error if it does not exist As the target of an assignment the value of the field is replaced if it exists or a new field is added otherwise if v itself is not defined a structure is created from scratch v itself may be an element or a field in a larger variable provided it is a structure or does not exists in an assignment i e complicated assignments like a 2 f 3 2 5 3 are accepted If V is a structure array V field is alvalue sequence which contains the specified field of each element of V The syntax v expr permits to specify the field name dynamically at run time as the result of evaluating expression expr v f is equivalent to v f This syntax is more elegant than functions getfield and setfield Examples s f 2 S f i 2 s g hello S f 2 s string s f 1 s f S f real 1x2 g string See also Operator O getfield settield Operator Addition LME Reference operators 113 Syntax x y M1 M2 M xX plus x y X M up lus x Description With t
50. the size of CA where dimension dim is removed Examples SA SA cell2struct 1 ab 2 cde cell2struct 1 2 ab cde See also struct2cell fieldnames List of fields of a structure Syntax fields fieldnames strct Description fieldnames strct returns the field names of structure strct as a list of strings Example fieldnames struct a 1 b 1 5 t a b See also getfield Value of a field in a structure 314 LyME User Manual 1999 2008 Calerga Sarl Syntax value getfield strct name Description getfield strct name gets the value of field name in structure strct It is an error if the field does not exist getfield s f gives the same value as s f getfield is especially useful when the field name is not fixed but is stored in a variable or is the result of an expression See also isfield Test for the existence of a field in a structure Syntax b isfield strct name Description isfield strct name is true if the structure strct has a field whose name is the string name false otherwise Examples isfield struct a 1 3 x abc x true isfield struct a 1 3 x abc X false See also jusstruct struct isstruct Test for a structure object LME Reference structures 315 Syntax b isstruct obj Description isstruct obj is true if its
51. utf8decode b str 308 LyME User Manual 1999 2008 Calerga Sarl 1x6 uint16 array 97 98 99 200 2000 20000 See also 3 20 List Functions apply Function evaluation with arguments in lists Syntax listout apply fun listin listout apply fun listin nargout Description listout apply fun listin evaluates function fun with input argu ments taken from the elements of list Listin Output arguments are grouped in list Listout Function fun is specified either by its name as a string or by an inline function The number of expected output arguments can be specified with an optional third input argument nargout By default the maximum number of output arguments is requested up to 256 this limit exists to prevent functions with an unlimited number of output arguments such as deal from filling memory Examples apply min 5 7 5 apply size magic 3 2 3 3 apply inline 2 x 3 y x y 5 10 40 See also LME Reference lists 309 join List concatenation Syntax list join ll 12 Description join 1l1 12 joins elements of lists 11 12 etc to make a larger list Examples join 1 a 2 5 4 2 xxx 1 a 2 3 4 5 4 2 xxx See also islist Test for a list object Syntax b islist obj Description islist obj is true if the object obj is a list false otherwise Examples islist 1 2 x
52. xlb and xub may have less elements than x or contain inf or inf corresponding elements have no lower and or upper bounds Examples Maximize 3x 2y subject to x y lt 9 3x y lt 18 x lt 7 andy lt 6 c 3 2 A 1 1 3 1 1 0 0 1 b 9 18 7 6 x linprog c A b oie AA 5 5 A more efficient way to solve the problem with bounds on variables c 3 2 A 1 1 3 1 b 9 18 xlb xub 7 6 212 LyME User Manual 1999 2008 Calerga Sarl X nprog c A b xlb xub li 4 5 4 5 Check that the solution is feasible and bounded all isfinite x true logm Matrix logarithm Syntax Y logm X Y err logm X Description logm X returns the matrix logarithm of X the inverse of the matrix exponential X must be square The matrix logarithm does not always exist With a second output argument err Logm also returns an estimate of the relative error norm expm lLogm X X norm X Example Logm 1 2 3 4 lt lt ll 0 3504 2 3911j 0 9294 1 0938j 1 394 1 6406j 1 0436 0 7505j expm Y 1 5 5511e 16j 2 7 7716e 16j 3 8 3267e 16j 4 See also lu LU decomposition LME Reference linear algebra 213 Syntax L U P lu A L2 U lu A Y lu A Description With three output arguments Lu A computes the LU decomposition of matrix A with partial pivoting i e a lower triangular matrix L an up per triangular matrix
53. 0 double strtrim tAB CD n r 0 65 66 32 32 67 68 See also deblank upper Convert all lowercase letters to lowercase Syntax s2 upper s1 Description upper s1 converts all the lowercase letters of string s1 to uppercase Currently only ASCII letters without diacritic are converted Example upper abcABC123 ABCABC123 See also Lower jisletter LME Reference strings 307 utf8decode Decode Unicode characters encoded with UTF 8 Syntax str utf8decode b Description utf8decode b decodes the contents of uint8 or int8 array b which represents Unicode characters encoded with UTF 8 Each Unicode character corresponds to one two or three bytes of UTF 8 code The result is a standard character array with a single row Invalid codes for example when the beginning of the decoded data does not correspond to a character boundary are ignored See also utf8encode utf8encode Encode a string of Unicode characters using UTF 8 Syntax b utf8encode str Description utf8encode b encodes the contents of character array str using UTF 8 Each Unicode character in str corresponds to one two or three bytes of UTF 8 code The result is an array of unsigned 8 bit integers If the input string does not contain Unicode characters the output is invalid Example b utf8encode abc 200 2000 20000 b 1x10 uint8 array 97 98 99 195 136 223 144 228 184 160 str
54. 1 2 7183 2 7183 2 7183 2 7183 See also fft Fast Fourier Transform Syntax F fft f F fft f n F fft f n dim Description fft f returns the discrete Fourier transform DFT of the vector f or the DFT s of each columns of the array f With a second argument n the n first values are used if n is larger than the length of the data zeros are added for padding An optional argument dim gives the dimension along which the DFT is performed it is 1 for calculating the DFT of the columns of f 2 for its rows and so on fft f dim specifies the dimension without resizing the array fft is based on a mixed radix Fast Fourier Transform if the data length is non prime It can be very slow if the data length has large prime factors or is a prime number The coefficients of the DFT are given from the zero frequency to the largest frequency one point less than the inverse of the sampling LME Reference linear algebra 203 period If the input f is real its DFT has symmetries and the first half contain all the relevant information Examples fft 1 4 10 2 2j 2 2 2j fft 1 4 3 6 1 5 0 866j 1 5 0 866j See also fft2 2 d Fast Fourier Transform Syntax F fft2 f F fft2 f size F fft2 f nr nc F fft2 f n Description fft2 f returns the 2 d Discrete Fourier Transform DFT along dimen sions 1 and 2 of array f With two or three input arguments f ft2 resizes the two first dimen sion
55. 1 i and j are equivalent Used as a suffix appended without space to a number i or j mark an imaginary number They must follow the fractional part and the exponent if any for single precision numbers they must precede the Single suffix To obtain a complex number i you can write either i or 1i or j or 1j The second way is safer because variables i and j are often used as indices and would hide the meaning of the built in functions The expression 11 is always interpreted as an imaginary constant number Imaginary numbers are displayed with i or j depending on the op tion set with the format command Examples i 1j format i 2i 2i 2single 5jsingle 2 5i single See also icdf Inverse cumulative distribution function Syntax X X X icdf distribution p icdf distribution p al icdf distribution p al a2 Description icdf distribution p calculates the value of x such that cdf distribution x is p The distribution is specified with the first argument a string case is ignored t and T are equivalent Additional arguments must be provided for some distributions The distributions are given in the table below Default values for the LME Reference mathematical functions 165 parameters when mentioned mean that the parameter may be omitted Distribution Name Parameters Beta beta aandb x chi2 deg of freedom v Y gamma shape q and scale A F f deg of freedom v and v2 lognormal logn
56. 1 2 3 4 evalfr sys 0 1j 3j ans 1x2x4 array 1 0 3333 0 5 2 0 25 0 25j 0 5 0 5j 3 5 8824e 2 0 2353 0 4 0 2j 4 8 3333e 2 8 3333e 2j 5 3846e 2 6 9231e 2j See also polyval ss ctrb Controllability matrix Syntax use lti C crtb a Description ctrb a gives the controllability matrix of system a which is full rank if and only if a is controllable See also SS ODSV Iti dcgain Steady state gain Syntax use lti g dcgain a 474 LyME User Manual 1999 2008 Calerga Sarl Description dcgain a gives the steady state gain of system a See also Uti inorm Iti feedback Feedback connection Syntax use lti c feedback a b c feedback a b sign c feedback a b ina outa c feedback a b ina outa sign Description feedback a b connects all the outputs of lti object a to all its inputs via the negative feedback Lti object b feedback a b sign applies positive feedback with weight sign the default value of sign is 1 feedback a b ina outa specifies which inputs and outputs of a to use for feedback The inputs and outputs of the result always cor respond to the ones of a See also Lti connect Iti inv System inverse Syntax use lti b inv a Description inv a gives the inverse of system a Libraries lti 475 See also ti mldivide lti mrdivide isct Test for a continous time LTI Synt
57. 1 2 3 4 5 1 4 10 2 25 See also Operator Scalar right division LME Reference operators 117 Syntax x y M1 M2 M X x M rdivide x y Description The first operand is divided by the second operand If both operands are matrices with a size different from 1 by 1 their size must be equal the division is performed element wise If one operand is a scalar it is repeated to match the size of the other operand rdivide x y is equivalent to x y It can be used to redefine this operator for objects Examples 3 10 3 5 12 See also Operator Matrix left division Syntax x y M1 M2 x M mldivide x y Description x y divides the second operand by the first operand If the first operand is a scalar it divides each element of the second operand Otherwise it must be a square matrix M1 M2 is equivalent to inv M1 M2 118 LyME User Manual 1999 2008 Calerga Sarl mldivide x y is equivalent to x y It can be used to redefine this operator for objects Examples 3 9 3 1 2 3 4 2 6 2 0 2 4 10 25 See also Operator Scalar left division Syntax M1 M2 M1 x ldivide x y Description The second operand is divided by the first operand If both operands are matrices with a size different from 1 by 1 their size must be equal the division is performed element wise If one operand is a scalar it is repeated to match the
58. 1 3 2 r 12345 See also det Determinant of a square matrix Syntax d det M Description det M is the determinant of the square matrix M which is O up to the rounding errors if Mis singular The function rank is a numerically more robust test for singularity Examples det 1 2 3 4 2 det 1 2 1 2 0 See also poly LME Reference linear algebra 199 diff Differences Syntax dm dm dm dm diff diff diff diff in n dim dim mnnn PEED Description diff A calculates the differences between each elements of the columns of matrix A or between each elements of A if it is a row vector diff A n calculates the n th order differences i e it repeats n times the same operation Up to a scalar factor the result is an ap proximation of the n th order derivative based on equidistant samples diff A n dim operates along dimension dim If the second argu ment n is the empty matrix the default value of 1 is assumed Examples diff 1 3 5 4 8 2 2 14 diff 1 3 5 4 8 2 0 35 diff 1 3 5 4 8 2 3 9 8 1 2 2 2 4 6 6 1 See also cumsum dlyap Discrete time Lyapunov equation Syntax X dlyap A C 200 LyME User Manual 1999 2008 Calerga Sarl Description dlyap A C calculates the solution X of the following discrete time Lyapunov equation AXA X C 0 All matrices are real 1 0505 3 2222 1 2117 3 2317 11 213 4 8234 1 4199 5 18
59. A perm Description ipermute A perm returns an array with the same elements as A but where dimensions are permuted according to the vector of dimensions perm It performs the inverse permutation of permute perm must contain integers from 1 to n dimension i in A becomes dimension perm i in the result Example size ipermute rand 3 4 5 2 3 1 534 See also isempty Test for empty matrices or empty lists Syntax b b isempty M isempty list Description isempty obj gives true if obj is the empty array the empty string or the empty list and false otherwise Examples isempty true isempty 0 false isempty 246 true isempty true isempty false See also iscell Test for cell arrays Syntax b iscell X Description LyME User Manual 1999 2008 Calerga Sarl iscell X gives true if X is a cell array or a list and false otherwise Examples iscell 1 2 true iscell 1 2 true islist 1 2 false See also islist ismember Test for set membership Syntax b ismember m s LME Reference arrays 247 Description ismember m s tests if elements of array m are members of set s The result is a logical array the same size as m each element is true if the corresponding element of m is a member of s or false otherwise m must be a numerical array or a cell array matching type of set s Example s a
60. B Q R Description dare A B Q calculates the stable solution X of the following discrete time algebraic Riccati equation X A XA A XB B XB I 71B XA Q All matrices are real Q and X are symmetric LME Reference linear algebra 197 With four input arguments dare A B Q R with R real symmetric solves the following Riccati equation X A XA A XB B XB R 1B XA Q With two or three output arguments X L K dare also re turns the gain matrix K defined as K B XB R B XA and the column vector of closed loop eigenvalues L eig A BK Example A 4 2 1 2 B 0 1 C 2 1 Q C C R 5 X L K dare A B Q R X 2327 9552 1047 113 1047 113 496 0624 L 0 2315 0 431 K 9 3492 2 1995 X A X A A X B B X B R B X A Q 1 0332e 9 4 6384e 10 4 8931e 10 2 2101e 10 See also care deconv Deconvolution or polynomial division Syntax q deconv a b q r deconv a b 198 LyME User Manual 1999 2008 Calerga Sarl Description q r deconv a b divides the polynomial a by the polynomial b re sulting in the quotient q and the remainder r All polynomials are given as vectors of coefficients highest power first The degree of the remainder is strictly smaller than the degree of b deconv is the inverse of conv a addpol conv b q r Examples q r deconv 1 2 3 4 5 1 3 2 q 1 14 r 6 3 addpol conv q
61. Here is an example of the use of polynom objects which as can be guessed from their name contain polynomials Statement use classes imports the definitions of methods for class polynom and oth ers use classes p polynom 1 5 0 1 p x 3 5x 241 q p2 3 p polynom 1 0 q X 64 10x 54 25x 44 2x 34 13x 2415x4 1 3 5 Input and Output LME identifies channels for input and output with non negative integer numbers called file descriptors File descriptors correspond to files devices such as serial port network connections etc They are used as input argument by most functions related to input and output such as fprintf for formatted data output or fgets for reading a line of text Note that the description below applies to most LME applications For some of them files command prompts or standard input are ir relevant or disabled and standard output does not always correspond to the screen At least four file descriptors are predefined Value Input Output Purpose 0 Input Standard input from keyboard 1 Output Standard output to screen 2 Output Standard error to screen 3 Output Prompt for commands You can use these file descriptors without calling any opening func tion first and you cannot close them For instance to display the value of m you can use fprintf fprintf 1 pi 6f n pi pi 3 141593 LME Reference 41 Some functions use implicitly one of these file descriptors For in
62. In aircraft coordinates vectors are 2 0 0 propeller position and 0 5 0 left wing tip The air craft attitude has a pitch of 10 degrees upward i e 10 degrees with the choice of axis and null roll and yaw q rpy2q 0 10 xpi 180 0 q 0 9962 0 0872j q quaternion 2 0 0 q 1 9696i 0 3473k q quaternion 0 5 0 q 5j See also q2rpy 3 32 Serial Port Functions Serial port functions enable communication with devices connected to the computer via an RS 232 interface Such devices include modems printers and many scientific instruments The operating system can also emulate RS 232 connections with other devices such as built in modems or USB Universal Serial Bus devices Functions described in this section include only those required for opening and configuring the connection They correspond to fopen for files Input output and control are done with the following generic functions Function Description fclose close the file fflush flush I O buffers fgetl read a line fgets read a line fprintf write formatted data fread read data fscanf read formatted data fwrite write data redirect redirect output Functions opendevice devicename closedevice and flushdevice are obsolete and may be removed in the future They are replaced with serialdevopen and serialdevset to specify configuration settings serialdevname fclose and fflush Serial port 383 serialdevname Serial device name Synt
63. LyME User Manual 1999 2008 Calerga Sarl lasterror message The robot is going to hit ground identifier robot hit See also eval Evaluate the contents of a string as an expression or statements Syntax x eval str_expression eval str_statement Description If eval has output argument s the input argument is evaluated as an expression whose result s is returned Without output arguments the input argument is evaluated as statement s eval can evaluate and assign to existing variables but cannot create new ones Examples eval 1 2 3 a eval 1 2 3 a 2 3 5 Il a eval a See also feval exist Existence of a function or variable Syntax b b exist name exist name type LME Reference miscellaneous functions 83 Description exist returns true if its argument is the name of an existing function or variable or false otherwise A second argument can restrict the lookup to builtin functions builtin user functions function or variable variable Examples exist sin true exist cos function false See also info feval Function evaluation Syntax argoutl feval fun arginl Description yl y2 feval fun x1 x2 evaluates function fun with in put arguments x1 x2 etc Output arguments are assigned to yl y2 etc Function fun is specified by either its name as a string a
64. Reference linear algebra 189 balance Diagonal similarity transform for balancing a matrix Syntax B balance A T B balance A Description balance A applies a diagonal similarity transform to the square ma trix A to make the rows and columns as close in norm as possible Balancing may reduce the 1 norm of the matrix and improves the accuracy of the computed eigenvalues and or eigenvectors To avoid round off errors balance scales A with powers of 2 balance returns the balanced matrix B which has the same eigen values and singular values as A and optionally the diagonal scaling matrix T such that T A T B Example A 1 2e6 3e 6 4 T B balance A T 16384 0 0 3 125e 2 B 1 3 8147 1 5729 4 See also eig care Continuous time algebraic Riccati equation Syntax X L K care A B Q X L K care A B Q R X L K care A B Q R S X L care A S Q true 190 LyME User Manual 1999 2008 Calerga Sarl Description care A B Q calculates the stable solution X of the following continuous time algebraic Riccati equation A X XA XBB X Q 0 All matrices are real Q and X are symmetric With four input arguments care A B Q R with R real symmetric solves the following Riccati equation A X XA XBR 1B X Q 0 With five input arguments care A B Q R S solves the following equation A X XA S XB R71 S B X Q 0 With two or three ou
65. Replicate an array Syntax A2 repmat Al n A2 repmat Al m n A2 repmat Al nl Description repmat creates an array with multiple copies of its first argument It can be seen as an extended version of ones where 1 is replaced by an arbitrary array The number of copies is m in the vertical direction and n in the horizontal direction The type of the first argument number character or logical value is preserved With a vector as second argu ment the array can be replicated along more than two dimensions 256 LyME User Manual 1999 2008 Calerga Sarl Examples repmat 1 2 3 4 1 2 1212 3434 repmat abc 3 abcabcabc abcabcabc abcabcabc See also reshape Rearrange the elements of an array to change its shape Syntax A2 reshape A1 A2 reshape Al nl n2 A2 reshape Al nl n2 Description reshape Al1 gives a column vector with all the elements of array Al which is read row wise If Al is a variable reshape Al is the same as Al reshape Al n1 n2 or reshape Al n1 n2 changes the dimensions of array A1 so that the result has m rows and n columns Al must have nl n2 elements read line wise both Al and the result have the same elements When dimensions are given as separate elements one of them can be replaced with the empty array it is replaced by the value such that the number of elements of the result matches the size of input array Example
66. Scripts To program a script in LyME tap the Edit button and new Replace untitled with a script name such as test Write your statements typically one per line below When you re ready tap OK or Load OK just stores your new script in the LyME database while Load also executes it Functions To program functions in LyME tap the Edit button and new Replace untitled with a library name such as stat or control Write all your functions below When you re satisfied tap OK or Load OK stores your new library in the LyME database while Load also issues a use command to LME Using LyME Figure 1 8 Figure 1 9 Figure 1 10 E AHE barirondi 107 stocked bergrmy OGS Ft gt ra ancal Library or script name calc _pi i for i 1 4 1000 weet in ietite end piapprox 4 x Cancel Library or script name mylib function b isprinetn b onytn 2 3 ln 3 8 allrnodin 2 3 2 sqrtine ee i ae er ere 10 LyME User Manual 1999 2008 Calerga Sarl CPi st Bs lt ae Eval clezfar i 1 100 if isprimegit fprintf dSn i endsend 67 71 73 79 83 a9 7 F olis t t 7sA f Figure 1 11 Edit Library or script name buglib function bugtn x zerosta for i 1 20 wie end Figure 1 12 to make your functions available from the command line You can then test your library To edit again your script or your library tap the Edit button then
67. See also sort pol2cart Polar to Cartesian coordinates transform Libraries stdlib 421 Syntax use stdlib x y pol2cart phi r x y Z pol2cart phi r z Description x y pol2cart phi r transforms polar coordinates phi and r to Cartesian coordinates x and y such that x rcos and x rsin x y zZ pol2cart phi r z transforms cylindrical coordinates to Cartesian coordinates leaving z unchanged Example use stdlib x y pol2cart 1 2 x 0806 1 y 1 6829 See also polyfit Polynomial fit Syntax use stdlib pol polyfit x y n Description polyfit x y n calculates the polynomial given as a vector of de scending power coefficients of order n which best fits the points given by vectors x and y The least square algorithm is used 422 LyME User Manual 1999 2008 Calerga Sarl Example use stdlib pol polyfit 1 5 2 1 4 5 2 3 pol 0 6667 5 5714 12 7619 9 8000 polyval pol 1 5 1 9429 1 2286 3 6571 5 2286 1 9429 polyvalm Value of a polynomial with square matrix argument Syntax use stdlib Y polyvalm pol X Description polyvalm pol X evaluates the polynomial given by the coefficients pol in descending power order with a square matrix argument Example use stdlib polyvalm 1 2 8 2 1 0 1 16 5 0 11 See also primes List of primes Syntax use stdlib v primes n Description primes n gives a row vector which
68. The statements between the for statement and the corresponding end are executed repeatedly with the control variable v taking succes sively every column of vect or every element of list List Typically vect is a row vector defined with the range operator You can change the value of the control variable in the loop how ever next time the loop is repeated that value is discarded and the next column of vect is fetched Examples for i 1 3 i end i i wI NI e Il LME Reference programming constructs 57 for i 1 3 i end 1 2 5 end i for i 1 3 break end i Treo RP WNe Il e for i m for el 1 abc 2 5 el end el 1 el abc el 2 5 See also variable assignment function endfunction Definition of a function operator or method Syntax function f statements function f x1 x2 statements function f xl x2 expr2 statements function y f x1 x2 statements function yl y2 x1 x2 statements function class method statements function 58 LyME User Manual 1999 2008 Calerga Sarl statements endfunction Description New functions can be written to extend the capabilities of LME They begin with a line containing the keyword function followed by the list of output arguments if any the function name and the list of input arguments between parenthesis if any The output argume
69. U and a permutation matrix P such that PxA L U If A in an m by n mytrix L is m by min m n U is min m n by n and P is m by m A can be rank deficient With two output arguments lu A permutes the lower triangular matrix and gives L2 P L such that A L2 U With a single output argument lu gives Y L U eye n Example X 1 2 3 4 5 6 7 8 8 L U P lu X L 1 0 0 0 143 1 0 0 571 0 5 1 U ba 7 8 8 0 0 857 1 857 0 0 0 5 P 001 100 010 P X L U ans 000 000 000 See also lyap Continuous time Lyapunov equation 214 LyME User Manual 1999 2008 Calerga Sarl Description lyap A B C calculates the solution X of the following continuous time Lyapunov equation AX XB C 0 All matrices are real With two input arguments lyap A C solves the following Lya punov equation AX XA C 0 Example 3 1 2 1 3 5 6 2 1 2 7 8 3 2 1 4 5 8 9 C A B C X lyap A B lt i oi i ou 0 1635 0 1244 0 2628 0 1311 0 7797 0 7645 See also dlyap max Maximum value of a vector or of two arguments Syntax x max v v ind max v v Plas dim v ind max M dim M3 es srs LME Reference linear algebra 215 Description max v returns the largest number of vector v NaN s are ignored The optional second output argument is the index of the maximum in v if several elements have the same maximum value only the first one is obtained The argument type can be
70. a b times a b a amp b and a b a b rdivide a b a lt b le a b a b ldivide a b a lt b lt a b a b mpower a b a gt b ge a b a b power a b a gt b gt a b a not a b eq a b a uminus a a b ne a b a uplus a a b same a b a ctranspose a a unsame a b a transpose a a b plus a b Operator which do not have a corresponding function are amp amp and because unlike functions they do not always evaluate all of their operands Operator Parenthesis index index select v select1 select2 v e v v v indexl index2 v v v Description A pair of parenthesis can be used to change the order of evaluation The subexpression it encloses is evaluated as a whole and used as if it was a Single object Parenthesis serve also to indicate a list of input or output parameters see the description of the function keyword The last use of parenthesis is for specifying some elements of an array or list variable Arrays In LME any numerical object is considered as an array of two dimensions or more Therefore at least two indices are required 106 LyME User Manual 1999 2008 Calerga Sarl to specify a single element the first index specifies the row the sec ond the column and so on In some circumstances however it is sometimes convenient to consider an array as a vector be it a column vector a row vector or even a matrix whose elements are indexed row w
71. a diagonal matrix or extraction of the diagonal elements of a matrix Syntax M diag v M diag v k v diag M v diag M k Description With a vector input argument diag v creates a square diagonal ma trix whose main diagonal is given by v With a second argument the diagonal is moved by that amount in the upper right direction for pos itive values and in the lower left direction for negative values With a matrix input argument the main diagonal is extracted and returned as a column vector A second argument can be used to spec ify another diagonal Examples 236 LyME User Manual 1999 2008 Calerga Sarl 0 OUO He Ww 3 NNO Q OONO H aOur Q H Q Q H m NRPQNMUOD AWOI Il ooooe Ko See also eye Identity matrix Syntax M eye n M eye m n M eye m n M eye type Description eye builds a matrix whose diagonal elements are 1 and other elements 0 The size of the matrix is specified by one integer for a square ma trix or two integers either as two arguments or in a vector of two elements for a rectangular matrix An additional input argument can be used to specify the type of the result It must be the string double single int8 int16 int32 int64 uint8 uint16 uint32 or uint64 64 bit arrays are not supported on all platforms LME Reference arrays 237 Examp
72. a higher precision See also alawexpand u Lawcompress alawexpand A law expander Syntax use sigenc output alawexpand input output alawexpand input a Libraries sigenc 491 Description alawexpand input a expands signal input with A law method using parameter a input can be a real array of any size and dimension The default value of a is 87 6 See also atlawcompress juLawexpand dpcmdeco Differential pulse code modulation decoding Syntax use sigenc output dpcmdeco i codebook predictor Description dpcmdeco i codebook predictor reconstructs a signal encoded with differential pulse code modulation It performs the opposite of dpcmenco See also dpcmenco Differential pulse code modulation encoding Syntax use Sigenc i dpcmenco input codebook partition predictor Description dpcmenco input codebook partition predictor quantizes the signal in vector input with differential pulse code modulation It predicts the future response with the finite impulse response filter given by polynomial predictor and it quantizes the residual error 492 LyME User Manual 1999 2008 Calerga Sarl with codebook and partition like quantiz The output i is an array of codes with the same size and dimension as input The prediction y k for sample k s degpredictor y k gt predictor yq k i i 1 where yg k is the quantized reconstructed signal The predictor must be strictly
73. also squareform prctile Percentile Syntax use stat m prctile A prc m prctile A prc dim Description prctile A prc gives the smallest values larger than prc percent of the elements of each column of array A or of the row vector A The dimension along which prctile proceeds may be specified with a third argument Libraries stat Example prctile rand 1 1000 90 0 8966 See also range Mean absolute deviation Syntax use stat m range A m range A dim Description 435 range A gives the differences between the maximum and minimum values of the columns of array A or of the row vector A The dimension along which range proceeds may be specified with a second argu ment Example range rand 1 100 0 9602 See also squareform Resize the output of pdist to a square matrix Syntax use stat D squareform d 436 LyME User Manual 1999 2008 Calerga Sarl Description squareform d resize d which should be the output of pdist into a symmetric square matrix D so that the distance between observations iand jisD i j See also pdist trimmean Trimmed mean of a set of values Syntax use stat m trimmean A prc m trimmean A prc dim Description trimmean A prc gives the arithmetic mean of the columns of array A or of the row vector A once prc 2 percent of the values have been re moved from each end The dimension along which trimmean proceeds may
74. and semantics where the values of variables in the current context can be LME Reference 39 captured implicitly without being listed as argument Their main use is aS argument to other functions Sets Sets are represented with numerical arrays of any type integer real or complex double or single character or logical or lists or cell ar rays of strings Members correspond to an element of the array or list All set related functions accept sets with multiple values which are always reduced to unique values with function unique They imple ment membership test union intersection difference and exclusive or Numerical sets can be mixed the result has the same type as when mixing numerical types in array concatenation Numerical sets and list or cell arrays os strings cannot be mixed Objects Objects are the basis of Object Oriented Programming OOP an ap proach of programming which puts the emphasis on encapsulated data with a known programmatic interface the objects Two OOP languages in common use today are C and Java The exact definition of OOP varies from person to person Here is what it means when it relates to LME Data encapsulation Objects contain data but the data cannot be accessed directly from the outside All accesses are performed via special functions called methods What links a particular method to a particular object is a class Class are identified with a name When an object is created its cla
75. anony mous function stored in variable fun fun x y x exp x y 2 x y 0 1 x 72 In Sysquake the contour plot can be displayed with the following com mands X Y meshgrid 0 0 02 3 0 0 02 3 contour feval fun X Y 0 3 0 3 0 1 0 05 0 5 The maximum is obtained by minimizing the opposite of the function rewritten to use as input a single variable in R mfun X X 1 exp X 1 X 2 2 X 1 X 2 0 1 X 1 2 fminsearch mfun 1 2 2 1444 0 3297 For the same function with a constraint x lt 1 the objective function can be modified to return co for inputs outside the feasible region note that we can start on the constraint boundary but starting from the infeasible region would probably fail mfunc X X 1 lt 1 X 1 exp X 1 X 2 2 X 1 X 2 O 1 X 1 2 inf fminsearch mfunc 1 2 1 0 7071 See also fzero Zero of a function Syntax x fzero fun x0 x fzero fun xlow xhigh x fzero options x fzero options LME Reference non linear numerical functions 281 Description fzero fun finds numerically a zero of function fun fun is either specified by its name or given as an anonymous or inline function or a function reference It has at least one input argument x and it returns one output argument also a real number fzero finds the value x such that fun x 0 up to some tolerance Second argument tells
76. are defined function yp relayfun t y yp y 2 function v te d relayevents t y v y 1 y 2 te false d sign y 2 function yn r yn y 2 elayonevent t y i The initial state is 0 1 O for the integrator and 1 for the output of the relay State is integrated during 5 s see Fig 3 4 with t y ode45 relayfun 0 5 0 1 odeset Events relayevents OnEvent relayonevent plot t y Delay differential equation A system whose Laplace transform is Y s U s e 9S s2 s first order integrator delay d is simulated with unit negative feedback The reference signal is 1 for t gt 0 First the open loop system is con verted from transfer function to state space such that x t Ax t 292 LyME User Manual 1999 2008 Calerga Sarl Bu t and y t Cx t d The closed loop state space model is ob tained by setting u t 1 y t which gives x t Ax t BCx t d Delayed state is interpolated from past results with interpl Note that values for t lt 0 extrapolated are set to 0 and that values more recent than the last result are interpolated with the state passed to f for current t A B C tf2ss 1 1 1 0 d 0 1 x0 zeros length A 1 tmax 10 f t x tpast xpast Axx B 1 C interp1 tpast t xpast x t d 1 0 t x ode45 f 0 tmax x0 odeset Past true Output y can be computed from
77. be specified with a third argument trimmean is less sensitive to outliers than the regular arithmetic mean See also zscore Z score normalized deviation Syntax use stat Y zscore X Y zscore X dim Libraries classes 437 Description zscore X normalizes the columns of array X or the row vector X by subtracting their mean and dividing by their standard deviation The dimension along which zscore proceeds may be specified with a sec ond argument 4 3 classes Library classes implements the constructors and methods of two classes polynom for polynomials and ratfun for rational functions Basic arithmetic operators and functions are overloaded to support expressions with the same syntax as for numbers and matrices The following statement makes available functions defined in classes use classes polynom polynom Polynom object constructor Syntax use classes a polynom a polynom coef Description polynom coef creates a polynom object initialized with the coeffi cients in vector coef given in descending powers of the variable Without argument polynom returns a polynom object initialized to 0 The following operators and functions may be used with polynom arguments with results analog to the corresponding functions of LME minus plus mpower rem mldivide roots mrdivide uminus mtimes uplus 438 LyME User Manual 1999 2008 Calerga Sarl Examples use classes p
78. causal predictor must be zero To encode the difference between in k and yq k 1 predictor 0 1 Note that there is no drift between the reconstructed signal and the input contrary to the case where the input is differentiated quantized and integrated Example use sigenc t 0 0 1 10 x Sin t codebook 1 01 1 partition 0 01 09 predictor 0 1 i dpcmenco x codebook partition predictor y dpcmdeco i codebook predictor See also dpcmopt Differential pulse code modulation decoding Syntax use sigenc predictor codebook partition dpcmopt in order n predictor codebook partition dpcmopt in order codebook0 predictor codebook partition dpcmopt in predictor predictor codebook partition dpcmopt tol predictor dpcmopt in order lActually there may be a drift if the arithmetic units used for encoding and decoding do not produce exactly the same results Libraries sigenc 493 Description dpcmopt in order n gives the optimal predictor of order order codebook of size n and partition to encode the signal in vector in with differential pulse code modulation The result can be used with dpcmenco to encode signals with similar properties If the second input argument is a vector it is used as the predictor and not optimized further its first element must be zero If the third input argument is a vector it is used as an initial guess fo
79. contains the primes up to n Libraries stdlib 423 Example use stdlib primes 20 2 3 5 71113 17 19 sortrows Sort matrix rows Syntax use stdlib S index sortrows M S index sortrows M sel S index sortrows M sel dim Description sortrows M sort the rows of matrix M The sort order is based on the first column of M then on the second one for rows with the same value in the first column and so on sortrows M sel use the columns specified in sel for comparing the rows of M A third argument dim can be used to specify the dimen sion of the sort 1 for sorting the rows or 2 for sorting the columns The second output argument of sortrows gives the new order of the rows or columns as a vector of indices Example use stdlib sortrows 3 1 2 2 2 1 2 1 2 2 1 2 2 2 1 3 1 2 See also sort sph2cart Spherical to Cartesian coordinates transform 424 LyME User Manual 1999 2008 Calerga Sarl Syntax use stdlib x y z sph2cart phi theta r Description x y z sph2cart phi theta r transforms polar coordinates phi theta and r to Cartesian coordinates x y and z such that x rcos g cos 9 y rsin g cos 9 and z rsin 9 Example use stdlib x y Z sph2cart 1 2 3 x 0 6745 y See also subspace Angle between two subspaces Syntax use stdlib theta subspace A B Description subspace A B gives the angle between the two subspaces spanne
80. creates an LTI object which represents the continuous time state space model t A x Cx t t Bu t Du ss A B C D Ts creates an LTI object which represents the discrete time state space model with sampling period Ts x k 1 y k In both cases if D is O it is resized to match the size of B and C if neces sary An additional argument var may be used to specify the variable of the Laplace s default or p or z transform z default or q ss A B C D b where b is an LTI object creates a state space model of the same kind continuous discrete time sampling time and variable as b ss b converts the LTI object b to a state space model Examples use lti sc ss 1 1 2 2 5 0 Sc continuous time LTI state space system A Libraries lti 467 1 B 1 2 C 2 5 D 0 0 0 0 sd ss tf 1 1 2 3 4 0 1 sd discrete time LTI state space system Ts 0 1 A 2 3 4 1 0 0 0 1 0 B 1 0 0 C 0 0 1 D 0 See also tf tf LTI transfer function constructor Syntax lti f num den a denlist f Ts f TS var f b f gain f b eo tou ud tt uo ou ut to u a a a a a a a a 468 LyME User Manual 1999 2008 Calerga Sarl Description tf num den creates an LTI object which represents the continuous time transfer function specified by descending power coefficient vec tors num and den tf num den Ts creates an LT
81. d array where each row corresponds to a sample and each column to a channel Its class is the same as the native type of the WAV file i e int8 or int16 Libraries wav 497 wavread filename n where n is a scalar integer reads the first n samples of the file wavread filename n1 n2 where the second input argument is a vector of two integers reads samples from n1 to n2 the first sample corresponds to 1 Instead of a file name string the first input argument can be a vector of bytes of class int8 or uint8 which represents directly the contents of the WAV file In addition to the samples wavread can return the sample rate in Hz such as 8000 for phone quality speech or 44100 for CD quality music and the number of bits per sample and channel See also Wwavwrite wavwrite WAV encoding Syntax use wav wavwrite samples samplerate nbits filename data wavwrite samples samplerate nbits data wavwrite samples samplerate Description wavwrite samples samplerate nbits filename writes a WAV file filename with samples in array samples sample rate samplerate in Hz and nbits bits per sample and channel Rows of samples corre sponds to samples and columns to channels nbits can be 8 or 16 With 2 or 3 input arguments wavwrite returns the contents of the WAV file as a vector of class uint8 The default word size is 16 bits per sample and channel Example use wav sr 44100 t O sr
82. double single or integer of any size max M operates on the columns of the matrix M and returns a row vector max M dim operates along dimension dim 1 for columns 2 for rows max M1 M2 returns a matrix whose elements are the maximum between the corresponding elements of the matrices M1 and M2 M1 and M2 must have the same size or be a scalar which can be compared against any matrix Examples mx ix max 1 3 2 5 8 7 mx 8 ix 5 max 1 3 5 nan 2 3 5 max 1 3 5 nan 2 2 3 5 2 See also min mean Arithmetic mean of a vector Syntax X mean v v mean M Vv mean M dim Description mean v returns the arithmetic mean of the elements of vector v mean M returns a row vector whose elements are the means of the 216 LyME User Manual 1999 2008 Calerga Sarl corresponding columns of matrix M mean M dim returns the mean of matrix M along dimension dim the result is a row vector if dim is 1 or a column vector if dim is 2 Examples mean 1 5 7 5 mean 1 5 7 5 mean 1 2 3 5 6 7 345 mean 1 2 3 5 6 7 1 345 mean 1 2 3 5 6 7 2 2 6 See also min Minimum value of a vector or of two arguments Syntax x v ind min v v min M dim min M dim M3 min M1 M2 Description min v returns the largest number of vector v NaN s are ignored The optional second smallest argument is the index of the minimum in v if several elements have th
83. function reference or an anonymous or inline function If a variable f contains a function reference or an anonymous or inline function f arguments is equivalent to feval f arguments Examples y feval sin 3 5 0 1411 0 7568 0 9589 feval x sin 2 x 3 5 0 2794 0 9894 0 544 x sin 2 x n 3 5 lt l fun y fu y 0 2794 0 9894 0 544 84 LyME User Manual 1999 2008 Calerga Sarl See also fevalx Function evaluation with array expansion Syntax Y1 fevalx fun X1 Description Y1 Y2 fevalx fun X1 X2 evaluates function fun with input arguments X1 X2 etc Arguments must be arrays which are ex panded if necessary along singleton dimensions so that all dimensions match For instance three arguments of size 3x1x2 1x5 and 1x1 are replicated into arrays of size 3x5x2 Output arguments are assigned to Y1 Y2 etc Function fun is specified by either by its name as a string a function reference or an inline function Example fevalx plus 1 5 10 10 30 11 12 13 14 15 21 22 23 24 25 31 32 33 34 35 See also fun2str Name of a function given by reference or source code of an inline function Syntax str fun2str funref str fun2str inlinefun LME Reference miscellaneous functions 85 Description fun2str funref gives the name of the function whose reference is funref fun2str inlinefun gives the source code of the inline function
84. function declaration it must be used as the last or unique output argument When the function is called with more LME Reference miscellaneous functions 99 output arguments than what can be obtained from the other argu ments remaining ones are extracted from the list varargout In the body of the function varargout is a normal variable Its value can be set globally with the brace notation or element by element with varargout i nargout may be used to know how many output arguments to produce Example Here is a function which differentiates a vector of values as many times as there are output arguments function varargout multidiff v for i 1 nargout v diff v varargout i v end In the call below 1 3 7 2 5 3 1 8 is differentiated four times v1 v2 v3 v4 multidiff 1 3 7 2 5 3 1 8 vl 2 4 5 3 2 2 7 v2 2 9 8 5 0 9 v3 11 17 13 5 9 v4 28 30 18 4 See also nargout varargin function variables Contents of the variables as a structure Syntax v variables Description variables returns a structure whose fields contain the variables de fined in the current context 100 LyME User Manual 1999 2008 Calerga Sarl See also warning Write a warning to the standard error channel Syntax warning msg warning format argl arg2 Description warning msg displays the string msg It should be used to notify the user about potential problems
85. functions 389 barh y x w barh kind barh kind style Description barh plots a bar plot with horizontal bars Please see bar for a de scription of its behavior and arguments Examples barh 2 4 3 6 3 5 4 1 barh 1 4 magic 4 stacked barh 1 4 2 4 3 1 5 6 4 6 interval simple bar plot stacked bar plot interval plot of of of See also beep Play music Syntax beep freq beep freq duration beep freq duration volume Description The beep command plays one or several sounds Argument is a m by n matrix with n between 1 and 3 first column is the frequency in Hertz second column is duration in seconds default 0 1 and third column is volume between 0 and 1 default 1 Example beep 440 2 12 12 See also audiop lay 390 LyME User Manual 1999 2008 Calerga Sarl cif Clear the figure window Syntax clf See also close Discard the graphics output and display the text output window Syntax close See also contour Level curves Syntax contour z contour z xmin xmax ymin ymax contour z xmin xmax ymin ymax levels Description contour z plots seven contour lines corresponding to the surface whose samples at equidistant points 1 size z 2 in the x direction and 1 size z 1 on the y direction are given by z Contour lines are at equidistant levels With a second non empty argument xmin xm
86. ifftn F size Description ifftn F returns the inverse n dimension Discrete Fourier Transform of array F inverse DFT along each dimension of F With two input arguments ifftn F size resizes F by cropping or by padding F with zeros 208 LyME User Manual 1999 2008 Calerga Sarl Up to the sign and a scaling factor the inverse n dimension DFT and the n dimension DFT are the same operation ifftn has the same syntax as See also hess Hessenberg reduction Syntax P H hess A H hess A Description hess A reduces the square matrix A A to the upper Hessenberg form H using an orthogonal similarity transformation P H P A The result H is zero below the first subdiagonal and has the same eigenvalues as A Example P H hess 1 2 3 4 5 6 7 8 9 P 1 0 0 0 0 4961 0 8682 0 0 8682 0 4961 H 1 3 597 0 2481 8 0623 14 0462 2 8308 0 0 8308 4 6154e 2 PxHxP ans 1 2 3 4 5 6 7 8 9 See also LME Reference linear algebra 209 inv Inverse of a square matrix Syntax M2 inv M1 Description inv M1 returns the inverse M2 of the square matrix M1 i e a matrix of the same size such that M2 M1 M1 M2 eye size M1 M1 must not be singular otherwise its elements are infinite To solve a set of linear of equations the operator is more efficient Example inv 1 2 3 4 2 1 1 5 0 5 See also kron Kronecker product Syntax M kron A B Description kr
87. is the current time The result is either a time as a 1 by 2 row vector or the empty array if the user taps the Cancel button Example tO selecttime Rocket launch time 12 0 Extensions audio output 399 See also selectday 3 36 Audio output This section describes functions which play sounds audioplay Play audio samples Syntax audioplay samples audioplay samples options Description audioplay samples plays the audio samples in array samples at a sample rate of 44 1 kHz Each column of samples is a channel i e samples is a column vector for monophonic sound and a two column array for stereophonic sound and each row is a sample Samples are stored as double or single numbers between 1 and 1 int8 numbers between 128 and 127 or int16 numbers between 32768 and 32767 audioplay samples options uses the specified options which are typically built with audioset Examples A monophonic bell like sound of two seconds with a frequency of 740 Hz and a damping time constant of 0 5 second t 0 88200 44100 samples sin 2 pix740 t exp t 0 5 audioplay samples Some white noise which oscillates 5 times between left and right t 0 44099 44100 noise 0 1 randn length t 1 left cos 2 pi t noise right sin 2 pi t noise opt audioset Repeat 5 audioplay left right opt 400 LyME User Manual 1999 2008 Calerga Sarl See a
88. just display the contents of a variable Tutorial 23 gt a 3 a 3 gt a 7 b 3 2x gt x a a 7 b 17 2 7 Loops and Conditional Execution To repeat the execution of some commands you can use either a for end block or a while end block With for you use a variable as a counter gt for i 1 3 i end With while the commands are repeated as long as some expression is true gt i 1 while i lt 10 i 2 x i end i You can choose to execute some commands only if a condition holds true gt if 2 lt 3 ok else amazing end ans ok 2 8 Functions LME permits you to extend its set of functions with your own This is convenient not only when you want to perform the same computation on different values but also to make you code clearer by dividing the whole task in smaller blocks and giving names to them To define a 24 LyME User Manual 1999 2008 Calerga Sarl new function you have to write its code in a file you cannot do it from the command line In Sysquake put them in a function block Functions begin with a header which specifies its name its input arguments parameters which are provided by the calling expression and its output arguments result of the function The input and out put arguments are optional The function header is followed by the code which is executed when the function is called This code can use arguments like any other variables We will first define a fu
89. long uze mylib Figure 1 16 automatically at startup Select Startup Commands in the File menu then type any command you want to be executed every time you launch LyME or Clear All Another useful command is info info l lists the currently loaded libraries info f lists all referenced functions with parenthesis for those not compiled yet info b lists the builtin functions and info v lists the variables with their type and size 1 3 User input The best way to develop reusable code is to write functions with in put and output arguments Variables can be created in the context of the command line to pass values between different functions and new values are entered directly in the command line with access to the history of past commands the list of functions and buttons for common operators and symbols It may also be useful to prompt the user for more input in the middle of a computation One mechanism can be used Standard input General input functions such as fgets or fscanf can be used with the predefined file descripor 0 The user can enter data and click button OK to resume execution or button Cancel to cancel it completely In the example below a single integer is requested note that the default file descriptor for fscanf is 0 n fscanf d Using LyME 13 1 4 Data exchange Libraries are synchronized during backup but those deleted on the Palm device are currently preserved on the desktop compute
90. mean 0 and st dev 1 normal norm mean 0 and st dev 1 Student s T t deg of freedom v uniform unif limits of the range 0 and 1 See also imag Imaginary part of a complex number Syntax im imag z Description imag z is the imaginary part of the complex number z or 0 if z is real Examples imag 1 2j 2 imag 1 0 See also inf Infinity 166 LyME User Manual 1999 2008 Calerga Sarl Syntax inf Inf inf n inf nl1 n2 inf n1 n2 inf type x X XXX X tou ot a od ou Description inf is the number which represents infinity Most mathematical func tions accept infinity as input argument and yield an infinite result if appropriate Infinity and minus infinity are two different quantities With integer non negative arguments inf creates arrays whose elements are infinity Arguments are interpreted the same way as zeros and ones The last argument of inf can be a string to specify the type of the result double for double precision default or single for single precision Examples 1 inf 0 inf inf See also isfinite Test for finiteness Syntax b isfinite x Description isfinite x is true if the input argument is a finite number neither infinite nor nan and false otherwise The result is performed on each element of the input argument and the result has the same size LME Reference mathematical functions Example isfinite 0 1 n
91. n is a double an int32 or a uint32 number 16 is n is an int16 or uint16 number or 8 if n is an int8 or uint8 number Without argument bitfield gives a bit field of 32 bits 0 Like any integer number in LME n may be written in base 2 8 10 or 16 0b1100 014 12 and Oxc all represent the same number The following operators and functions may be used with bitfield arguments with results analog to the corresponding functions of LME Logical functions operate bitwise amp and not eq or minus plus mldivide uminus mrdivide uplus mtimes xor ne Indexes into bit fields are non negative integers 0 represents the least significant bit and wordlength 1 the most significant bit Unlike arrays bits are not selected with logical arrays but with other bit fields where ones represent the bits to be selected for example a 0b1011 selects bits 0 1 and 3 This is consistent with the way bitfield find is defined Examples use bitfield a bitfield 123 16 a 0b0000000001111011 b a o 0b1111111110000100 b a gt 5 o 0b0000001001100111 See also bitfield disp bitfield double bitfield disp Display a bitfield object Libraries bitfield 451 Syntax use bitfield disp a Description disp a displays bitfield a It is also executed implicitly when LME displays the bitfield result of an expression which does not end with a semicolon See also bitfield double
92. n k gives the number of combinations of n objects taken k at a time Both n and k must be nonnegative integers with k lt n Examples nchoosek 10 4 210 nchoosek 10 6 210 See also nthroot Real nth root Syntax y nthroot x n Description nthroot x n gives the real nth root of real number x If x is positive it is x 1 n if x is negative it is abs x 1 n if n is an odd integer or NaN otherwise Example nthroot 2 2 3 1 2599 1 2599 2 2 1 3 0 63004 1 0911i1 1 2599 See also LME Reference mathematical functions 177 pdf Probability density function Syntax pdf distribution x pdf distribution x al pdf distribution x al a2 y y y Description pdf distribution x gives the probability of a density function The distribution is specified with the first argument a string case is ig nored t and T are equivalent Additional arguments must be pro vided for some distributions See cdf for the list of distributions See also cdf pi Constant Tr Syntax x pi Description pi is the number r up to the precision of its floating point represen tation Example exp 1j pi 1 See also 178 LyME User Manual 1999 2008 Calerga Sarl real Real part of a complex number Syntax re real z Description real z is the real part of the complex number z or z if z is real Examples real 1 2j 1 real 1 1
93. nargin product of elements of x Prod prod x else product of x and y Prod x y end end Two equivalent definitions function S area a b a ellipse false S ellipse pit a xb 4 ax b function S area a b ellipse if nargin lt 2 b a end if nargin lt 3 ellipse false end S ellipse pix axb 4 ax b See also if elseif else end Conditional execution depending on the value of one or more boolean expressions 60 Syntax if expr sl end if expr sl else s2 end if expr1 s1 elseif expr2 s2 else s3 end Description LyME User Manual 1999 2008 Calerga S rl If the expression following if is true nonempty and all elements dif ferent from 0 and false the statements which follow are executed Otherwise the expressions following elseif are evaluated until one of them is true If all expressions are false the statements following else are executed Both elseif and else are optional Example if x gt 2 disp large elseif x gt 1 disp medium else disp small end See also LME Reference programming constructs 61 include Include libraries Syntax include lib Description include lib inserts the contents of the library file lib Its effect is similar to the use statement except that the functions and constants in lib are defined in the same context as the library where include is located
94. of optimset Remaining input arguments of fminsearch if any are given as ad ditional input arguments to function fun They permit to parameterize the function For example fminsearch fun x0 2 5 calls fun as fun x 2 5 and minimizes its value with respect to x The first output argument of fminsearch is the value of x at opti mum The second output argument if it exists is the value of fun x at optimum The third output argument if it exists is set to true if fminsearch has converged to an optimum or to false if it has not in that case other output arguments are set to the best value obtained With one or two output arguments fminsearch throws an error if it does not converge Algorithm fminsearch implements the Nelder Mead simplex method It starts from a polyhedron centered around x0 the simplex Then at each it eration either vertex x_i with the maximum value fun x_i is moved to decrease it with a reflexion expansion a reflexion or a contraction or the simplex is shrinked around the vertex with minimum value It erations stop when the simplex is smaller than the tolerance or when the maximum number of iterations or function evaluations is reached then an error is thrown 280 LyME User Manual 1999 2008 Calerga Sarl Examples Minimum of a sine near 2 displayed with 15 digits fprintf 15g n fminsearch sin 2 4 712388977408411 Maximum of xe Y xy 0 1x The function if defined as an
95. one or the second one Compilation overflow Not enough memory during compilation Too many nested subexpressions The number of nested of subexpressions is too high Variable table overflow A single statement attempts to define too many new variables at once Expression too large Not enough memory to compile a large ex pression Too many nested and The maximum depth of nested subexpressions function argument lists arrays and lists is reached Too many nested programming structures Not enough mem ory to compile that many nested programming structures such as if while switch etc Wrong number of input arguments Too few or too many input arguments for a built in function during compilation Wrong number of output arguments Too few or too many out put arguments for a built in function during compilation Too many indices More than two indices for a variable Variable not found A variable is referenced but appears neither in the arguments of the function nor in the left part of an assign ment Unbounded language construct if while for switch or try without end Unexpected end The end statement does not match an if Switch while for or catch block LME Reference 45 case or otherwise without switch The case or otherwise statement is not inside a switch block catch without try The catch statement does not match a try block break or continue not in a loop The break or continue
96. operators 133 Description x1 x2 gives a row vector with the elements x1 x1 1 x1 2 etc until x2 The last element is equal to x2 only if x2 x1 is an integer and smaller otherwise If x2 lt x1 the result is an empty matrix x1 step x2 gives a row vector with the elements x1 x1 step x1 2 step etc until x2 The last element is equal to x2 only if x2 x1 step is an integer With fractional numbers rounding er rors may cause x2 to be discarded even if x2 x1 step is almost an integer If x2 sign step lt x1l sign step the result is an empty matrix If x1 or step is complex a complex vector is produced with the expected contents The following algorithm is used to generate each element z xl while real z x1 x2 x1 lt 1 add z to the vector z Z step end This algorithm is robust enough to stop even if x2 is not on the complex straight line defined by x1 and step If x2 x1 and step are orthogonal it is attempted to produce an infinite number of elements which will obviously trigger an out of memory error This is similar to having a null step in the real case Note that the default step value is always 1 for consistency with real values Choosing for instance sign x2 x1 would have made the generation of lists of indices more difficult Hence for a vector of purely imaginary numbers always specify a step colon x1 x2 is equivalent to x1 x2 and colon x1 step x2 to x1 step x2 It can be used to redefine
97. or linear linear See also griddatan Data interpolation in N d space Syntax vi vi griddatan x v xi griddatan x v xi method Description griddatan x v xi interpolates values at coordinates given by the p rows of p by n array xi in an n dimension space Original data are defined by m by n array x and m by 1 column vector v such that the value at coordinate x i is v i The result is a p by 1 column vector vi where vi j is the value interpolated at xi j Coordinates x and xi are real imaginary components are ignored Values v and vi can be real or complex The result for coordinates outside the convex hull defined by x is NaN griddatan is based on Delaunay triangulation The interpolation method used in each simplex is linear by default or can be specified with an additional input argument a string Argument Meaning 0 or nearest nearest value 1 or linear linear See also de lLaunayn tsearcnn griddata jinterpn tsearch Search of points in triangles LME Reference triangulation 271 Syntax ix tsearch x y t xi yi Description tsearch x y t xi yi searches in which triangle is located each point given by the corresponding elements of arrays xi and yi Corresponding elements of arrays x and y represent the vertices of the triangles and rows of array t represent their indices in x and y array t is usually the result of delaunay Dimensions of x and y
98. pick its name from the list The Load button will remove the previous definitions and replace them with the new ones Error correction When you execute a function and an error occurs the library name the function name and the line number are displayed If you tap some where on the library or function name then tap the Edit button LyME displays directly the offending line to help you correct the bug Here is an example of a problematic function Tap Load then write bugfn LyME stops when it tries to write to the 10th element of the 3 by 3 matrix Using LyME 11 Ly Mie EDEN T CARS gla Bod size buglib bugtn 5 x Figure 1 13 Canal Library or script nome buglib function bugtn x zerost3 for i 1 20 end Figure 1 14 Tap the function name in the error message bugfn then tap the Edit button to jump to the line where the error occurred Using libraries To use a library when you restart LyME tap the Ld load button and the name of the library The command to do the same is use library name You can also use this command in another library note however that functions in nested libraries are hidden unless their library is explicitly used where they are called If you use frequently the same libraries you may want to use them Lyme Ome eee use my lib Figure 1 15 12 LyME User Manual 1999 2008 Calerga Sarl Startup commands i commands run when LME is launched or when LWE is cleared format
99. result when the input requires it even if it is real gt sqrt 2 ans 04 1 4142i gt exp 3 2j Tutorial 17 ans 8 3585 18 2637j gt log 8 3585 18 2637j ans 3 2j To get the real or imaginary part of a complex number use the func tions real or imag respectively gt real 2 3j ans 2 gt imag 2 3j ans 3 Complex numbers can be seen as vectors in a plane Then addition and subtraction of complex numbers correspond to the same opera tions applied to the vectors The absolute value of a complex number also called its magnitude is the length of the vector gt abs 3 4j ans 5 gt sqrt 3 2 4 2 ans 5 The argument of a complex number is the angle between the x axis real axis and the vector counterclockwise It is calculated by the angle function gt angle 2 3j ans 0 9828 The last function specific to complex numbers we will mention here is conj which calculates the conjugate of a complex number The con jugate is simply the original number where the sign of the imaginary part is changed gt conj 2 3j ans 2 3j Real numbers are also complex numbers with a null imaginary part hence gt abs 3 ans 18 LyME User Manual 1999 2008 Calerga Sarl gt conj 3 ans gt angle 3 ans gt angle 3 ans 3 1416 2 3 Vectors and Matrices LME manipulates vectors and matrices as easily as scalars To define a matrix enclose its contents
100. stance disp displays a value to file descriptor 1 and warning displays a warning message to file descriptor 2 File descriptors for files and devices are obtained with specific func tions For instance fopen is used for reading from or writing to a file These functions have as input arguments values which specify what to open and how file name host name on a network input or output mode etc and as output argument a file descriptor Such file de scriptors are valid until a call to fclose which closes the file or the connection 3 6 Error Messages When an error occurs the execution is interrupted and an error mes sage explaining what happened is displayed unless the code is en closed in a try catch block The whole error message can look like gt use stat gt igqr 123 Index out of range for variable M stat prctile 61 gt stat iqr 69 The first line contains an error message the location in the source code where the error occurred and the name of the function or oper ator involved Here stat is the library name prctile is the function name and 61 is the line number in the file which contains the library If the function where the error occurs is called itself by another func tion the whole chain of calls is displayed here prctile was called by iqr at line 69 in library stat Here is the list of errors which can occur For some of them LME attempts to solve the problem itself e g by allocating more memor
101. stat S nancorrcoef X S nancorrcoef X1 X2 Description nancorrcoef X calculates the correlation coefficients of the columns of the m by n matrix X NaN values are ignored The result is a square n by n matrix whose diagonal is 1 nancorrcoef X1 X2 calculates the correlation coefficients of X1 and X2 and returns a 2 by 2 matrix ignoring NaN values It is equiva lent to nancorrcoef X1 X2 See also nancov Covariance after discarding NaNs Syntax use stat M nancov data M nancov data 0 M nancov data 1 Description nancov data returns the best unbiased estimate m by m covariance matrix of the n by m matrix data for a normal distribution NaN values are ignored Each row of data is an observation where n quantities were measured nancov data Q is the same as nancov data nancov data 1 returns the m by m covariance matrix of the n by m matrix data which contains the whole population NaN values are ignored Libraries stat 431 See also nanmean Mean after discarding NaNs Syntax use stat y nanmean A y nanmean A dim Description nanmean v returns the arithmetic mean of the elements of vector v nanmean A returns a row vector whose elements are the means of the corresponding columns of array A nanmean A dim returns the mean of array A along dimension dim the result is a row vector if dim is 1 or a column vector if dim is 2 In all cases NaN values are ignored Example
102. statement is not inside a while or for block Variable name reused Same variable used twice as input or as output argument Too many user functions Not enough memory for that many user functions Attempt to redefine a function A function with the same name already exists Can t find function definition Cannot find a function definition during compilation Unexpected end of expression Missing right parenthesis or square bracket Unexpected statement Expression expected but a statement is found e g if Null name Name without any character when given as a string in functions like feval and struct Name too long More than 32 characters in a variable or function name Unexpected function header A function header keyword func tion has been found in an invalid place for example in the argu ment of eval Function header expected A function header was expected but not found Bad variable in the left part of an assignment The left part of an assignment does not contain a variable a structure field a list element or the part of an array which can be assigned to Bad variable in a for loop The left part of the assignment of a for loop is not a variable Source code not found The source code of a function is not avail able File not found fopen does not find the file specified 46 LyME User Manual 1999 2008 Calerga Sarl Bad file ID_ 1 O function with a file descriptor which neither is stan dard nor cor
103. stdlib is a library which extends the native LME functions in the fol lowing areas creation of matrices blkdiag compan hankel linspace logspace toeplitz geometry cart2sph cart2pol pol2cart sph2cart subspace functions on integers primes statistics corrcoef median perms data processing circshift cumtrapz fftshift filter2 hist ifftshift polyfit polyvalm trapz other isreal sortrows The following statement makes available functions defined in stdlib use stdlib cart2pol Cartesian to polar coordinates transform Syntax use stdlib phi r cart2pol x y phi r z cart2pol x y z Description phi r cart2pol x y transforms Cartesian coordinates x and y to polar coordinates phi and r such that x rcos and x r sin phi r z cart2pol x y z transform Cartesian coordinates to cylindrical coordinates leaving z unchanged Example use stdlib phi r cart2pol 1 2 phi 1 1071 r 2 2361 Libraries stdlib 411 See also polzcart cart2sph Cartesian to spherical coordinates transform Syntax use stdlib phi theta r cart2sph x y zZ Description phi theta r cart2sph x y z transforms Cartesian coordinates x y and z to polar coordinates phi theta and r such that x rcos g cos 9 y rsin g cos 9 and z rsin 9 Example use stdlib phi theta r cart2sph 1 2 3 phi 1 1071 theta 0 9303 r 3 7417 See also
104. that this function does not return the same result as the strcmp function of the standard C library Examples strcemp abc abc true strcmp abc def false strcmp abc abd 2 true strcmp abc abc 5 false See also strcmpi String comparison with ignoring letter case Syntax b strcmpi sl1 s2 b strcmpi sl s2 n Description strcmpi compares strings for equality ignoring letter case In every other respect it behaves like strcmp 304 LyME User Manual 1999 2008 Calerga Sarl Examples strcmpi abc aBc true strcmpi Abc abd 2 true See also strmatch String match Syntax i i i strmatch str strMatrix strmatch str strList strmatch exact Description strmatch str strMatrix compares string str with each row of the character matrix strMatrix it returns the index of the first row whose beginning is equal to str or 0 if no match is found Case is significant strmatch str strList compares string str with each element of list strList which must be strings With a third argument which must be the string exact str must match the complete row or element of the second argument not only the beginning Examples strmatch abc axyz uabc abcd efgh 3 strmatch abc axyz uabc abcd efgh exact 0 strmatch abc ABC axyz
105. the 2 by 3 matrix 1 1 1 2 2 2 In an expression used as the second of multiple subscripts to access some elements of an array A expr or A expr matrixcol gives a row vector of length size A 2 whose elements are the indices of each column It is equivalent to the range beginning end matrixcol is useful in boolean expressions to select some ele ments of an array matrixcol can be overloaded for objects of used defined classes Its definition should have a header equivalent to function e C matrixcol obj i n where C is the name of the class obj is the object to be indexed i is the position of the index expression where matrixcol is used and n is the total number of index expressions Example Set to 0 the NaN values which are not in the first column A 1 nan 5 nan 7 2 3 1 2 A matrixcol gt 1 amp isnan A 0 A LME Reference variables 51 1 0 5 nan 7 2 3 1 2 See also matrixrow beginning matrixrow First index in a subscript expression Syntax A matrixrow function e C matrixrow obj i n Description In an expression used as a single subscript to access some elements of an array A expr matrixrow gives an array of the same size as A where each element is the row index For instance for a 2 by 3 matrix matrixrow gives the 2 by 3 matrix 1 2 3 1 2 3 In an expression used as the first of multiple subscripts to access some elements of an array A expr matrix
106. the corresponding columns of Q are discarded With column pivoting the third output argument e is a permutation vector A e Q R Example Q R qr 1 2 3 4 5 6 Q 0 169 0 8971 0 4082 0 5071 0 276 0 8165 0 8452 0 345 0 4082 R 5 9161 7 4374 0 0 8281 0 0 Q R qr 1 2 3 4 5 6 false Q 0 169 0 8971 0 5071 0 276 0 8452 0 345 R 5 9161 7 4374 0 0 8281 See also rank Rank of a matrix Syntax x rank M x rank M e 226 LyME User Manual 1999 2008 Calerga Sarl Description rank M returns the rank of matrix M i e the number of lines or columns linearly independent To obtain it the singular values are computed and the number of values significantly larger than O is counted The value below which they are considered to be 0 can be specified with the optional second argument Examples rank 1 1 0 0 1 rank 1 1 0 1j 2 See also roots Roots of a polynomial Syntax r r r roots pol roots M roots M dim Description roots pol calculates the roots of the polynomial pol The polyno mial is given by the vector of its coefficients highest power first while the result is a column vector With a matrix as argument roots M calculates the roots of the polynomials corresponding to each column of M An optional second argument is used to specify in which dimension roots operates 1 for columns 2 for rows The roots of the i th polynomial are in the i th column o
107. the state y C x interpl t x t d 1 0 See also optimset Options for minimization and zero finding Syntax options optimset options optimset namel valuel options optimset options0O namel valuel Description optimset namel valuel creates the option argument used by fminbnd fminsearch and fzero Options are specified with name value pairs where the name is a string which must match exactly the names in the table below Case is significant Options which are not specified have a default value The result is a structure whose fields correspond to each option Without any input argument optimset creates a structure with all the default options Note that fminbnd fminsearch and fzero also interpret the lack of an option argument or the empty array as a request to use the default values LME Reference non linear numerical functions 293 When its first input argument is a structure optimset adds or changes fields which correspond to the name value pairs which fol low Here is the list of permissible options empty arrays mean auto matic Name Default Meaning Display false detailed display MaxFunEvals 1000 maximum number of evaluations MaxIter 500 maximum number of iterations TolXx maximum relative error The default value of TolX is eps for fzero and sqrt eps for fminbnd and fminsearch Examples Default options optimset Display false MaxFunEvals 1000 M
108. this operator for objects The colon character is also used to separate the alternatives of a conditional expression b x y Example 2 D ul 2 Www D ul m A oO foe Ww INNGFINWWNUN UI m N 134 LyME User Manual 1999 2008 Calerga Sarl 5432 0 1j 10j 1j 2j 3j 4j 5j 6j 7j 8j 9j 10j 1 1 1j 5 4j 1 2 1j 3 2j 4 3j 5 4j 0 1 1j 5 1 1j 2 2j 3 3j 4 4j 5 5j See also Operator Function reference or anonymous function Syntax fun arguments expression Description fun gives a reference to function fun which can be used wherever an inline function can Its main use is as the argument of functions like feval or quad but it may also be stored in lists cell arrays or structures A reference cannot be cast to a double unlike characters or logical values nor can it be stored in an array Anonymous functions are an alternative more compact syntax for inline functions In args expr args is a list of input arguments and expr is an expression which contains two kinds of variables input arguments provided when the anonymous expression is executed captured variables all variables which do not appear in the list of input arguments which have the value of variables of the same name existing when and where the anonymous function is created These values are fixed If the top level element of the anonymous function is itself a function multiple output arguments can be
109. throwing an error The optional second output argument always gives the number of elements in the result With a third argument fread fd size precision reads inte ger words of 1 2 or 4 bytes or IEEE floating point numbers of 4 bytes single precision or 8 bytes double precision The meaning of the string precision is described in the table below precision meaning int8 signed 8 bit integer 128 lt x lt 127 char signed 8 bit integer 128 lt x lt 127 int16 signed 16 bit integer 32768 lt x lt 32767 int32 signed 32 bit integer 2147483648 lt x lt 2147483647 int64 signed 64 bit integer 9 223372e18 lt x lt 9 223372e18 uint8 unsigned 8 bit integer 0 lt x lt 255 uchar unsigned 8 bit integer 0 lt x lt 255 uint16 unsigned 16 bit integer 0 lt x lt 65535 uint32 unsigned 32 bit integer 0 lt x lt 4294967295 uint64 unsigned 64 bit integer 0 lt x lt 18 446744e18 single 32 bit IEEE floating point double 64 bit IEEE floating point By default multibyte words are encoded with the least significant byte first little endian The characters b can be appended to spec ify that they are encoded with the most significant byte first big en dian for symmetry U is accepted and ignored By default the output is a double array To get an output which has the same type as what is specified by precision the character can be inserted at the beginning For instance
110. trapz 2 3 5 6 5 trapz 1 2 5 2 3 5 14 5 See also 4 2 stat stat is a library which adds to LME advanced statistical functions The following statement makes available functions defined in stat use stat bootstrp Bootstrap estimate Syntax use stat stats samples bootstrp n fun D1 Libraries stat 427 Description bootstrp n fun D picks random observations from the rows of ma trix or column vector D to form n sets which have all the same size as D then it applies function fun a function name or reference or an inline function to each set and returns the results in the columns of stats Up to three different set of data can be provided bootstrp gives an idea of the robustness of the estimate with re spect to the choice of the observations Example use stat D rand 1000 1 bootstrp 5 std D 0 2938 0 2878 0 2793 0 2859 0 2844 geomean Geometric mean of a set of values Syntax use stat m geomean A m geomean A dim Description geomean A gives the geometric mean of the columns of array A or of the row vector A The dimension along which geomean proceeds may be specified with a second argument The geometric mean of vector v of length n is defined as vo Example use stat geomean 1 10 4 5287 mean 1 10 5 5 exp mean log 1 10 4 5287 428 See also harmmean LyME User Manual 1999 2008 Calerga Sarl Harmonic mean of a set of
111. type changes the numeric array X to the type given by string type which can be double single int8 or any other signed or unsigned integer type char or logical The binary representation in memory is preserved The imaginary part if any is discarded Depending on the conversion the number of elements is changed so that the array size in bytes in preserved The result is a row vector if X is a scalar or a row vector or a column vector otherwise The result depends on the computer architecture 188 LyME User Manual 1999 2008 Calerga Sarl Example typecast luint32 uint8 1x4 uint8 array 0 0 0 1 typecast pi uint8 1x8 uint8 array 64 9 33 251 84 68 45 24 See also swapbytes 3 14 Linear Algebra addpol Addition of two polynomials Syntax p addpol p1 p2 Description addpol p1 p2 adds two polynomials p1 and p2 Each polynomial is given as a vector of coefficients with the highest power first e g x 2x 3 is represented by 1 2 3 Row vectors and column vectors are accepted as well as matrices made of row vectors or col umn vectors provided one matrix is not larger in one dimension and smaller in the other one addpol is equivalent to the plain addition when both arguments have the same size Examples addpol 1 2 3 2 5 148 addpol 1 2 3 2 5 subtraction 10 2 addpol 1 2 3 4 5 6 1 1 124 457 See also conv deconv Operator LME
112. used once at the beginning of the block to be timed See also toc Elapsed time of stopwatch Syntax elapsed_time toc 370 LyME User Manual 1999 2008 Calerga Sarl Description toc gets the time elapsed since the last execution of tic Typically toc is used at the end of the block of statements to be timed On multi tasking operating systems like Windows Mac OS X and Unix toc measures only the time spent in the LME application Other processes do not have a large impact For instance typing tic at the command line prompt waiting 5 seconds and typing toc will show a value much smaller than 5 Example tic x eig rand 200 toc 0 3046 See also 3 30 Date Conversion Functions Date functions perform date and time conversions between the calen dar date and the julian date The calendar date is the date of the proleptic Gregorian calendar i e the calendar used in most countries today where centennial years are not leap unless they are a multiple of 400 This calendar was introduced by Pope Gregory XIII on October 5 1582 Julian Calendar the calendar used until then which became October 15 The calendar used in this library is proleptic which means the rule for leap years is applied back to the past before its introduction Negative years are permitted the year 0 does exist The julian date is the number of days since the reference point January 1st 4713 B C Julian calendar at noon The fractional
113. useful with slow devices without handshake When text mode is set input CR and CR LF sequences are con verted to LF Output CR and LF are not converted Depending on the platform operations which use the timeout value such as input can be interrupted with the platform dependent abort key s typically Escape or Control C or are limited to 10 seconds Example serialdevset BPS 19200 Handshake false StopBits 2 TextMode false Timeout 1 See also serialdevopen serialdevname 3 33 Long Integers This section describes functions which support long integers ongint i e integer numbers with an arbitrary number of digits limited only by the memory available Some LME functions have been overloaded new definitions have been added and are used when at least one of their arguments is of type longint These functions are listed in the table below 386 LME abs char disp double gcd Lom minus mldivide mpower mrdivide mtimes plus rem uminus uplus longint Operator N LyME User Manual 1999 2008 Calerga Sarl Purpose absolute value conversion to string display conversion to floating point greatest common divisor least common multiple subtraction left division power right division multiplication addition remainder negation no operation Creation of a long integer Syntax li li Description Longint i Longint str longint i creates a long integer from a n
114. variable A and s is a structure with two fields s type which is and s subs which is the list containing the single subscript s When the field of an object variable is retrieved in an expression like A f LME executes subsref A s where s is a structure with two fields s type which is and s subs which is the name of the field f in this case While the primary purpose of subsref is to permit the use of sub scripts with objects a built in implementation of subsref is provided for arrays when s type is for lists when s type is and for structures when s typeis Examples A 1 2 3 4 subsref A struct type subs 1 12 See also 3 8 Programming Constructs Programming constructs are the backbone of any LME program Ex cept for the variable assignment all of them use reserved keywords which may not be used to name variables or functions In addition to the constructs described below the following keywords are reserved for future use 54 LyME User Manual 1999 2008 Calerga Sarl classdef goto break Terminate loop immediately Syntax break Description When a break statement is executed in the scope of a loop construct while repeat or for the loop is terminated Execution continues at the statement which follows end Only the innermost loop where break is located is terminated The loop must be in the same function as break I
115. vector A The dimension along which skewness proceeds may be specified with a second argument The skewness measures how asymmetric a distribution is It is 0 for a symmetric distribution and positive for a distribution which has more values much larger than the mean Example skewness randn 1 10000 2 2 6833 See also sqrtm Matrix square root LME Reference linear algebra 229 Syntax Y sqrtm X Y err sqrtm X Description sqrtm X returns the matrix square root of X such that sqrtm X 2 X X must be square The matrix square root does not always exist With a second output argument err sqrtmalso returns an estimate of the relative error norm sqrtm X 2 X norm X Example Y sqrtm 1 2 3 4 Y 0 5537 0 4644j 0 807 0 2124j 1 2104 0 3186 1 7641 0 1458j Y 2 1 2 3 4 See also std Standard deviation Syntax p p p dim lt lt lt lt XX tou uw ue ou wn t Q zzz lt lt Description std v gives the standard deviation of vector v normalized by length v 1 With a second argument std v p normalizes by length v 1 if p is true or by length v if p is false std M gives a row vector which contains the standard deviation of the columns of M With a third argument std M p dim operates along dimension dim 230 LyME User Manual 1999 2008 Calerga Sarl Example std 1 2 5 6 10 12 4 3359 See also sum Sum of the elements of a vector S
116. where a is any kind of LTI object gives the four matrices of the state space model and optionally the sampling period or the empty array for continuous time systems Libraries lti 483 See also ti tfdata Iti subsasgn Assignment to a part of an LTI system Syntax use lti var i j a var ix a var select a var field value a subsasgn a s b Description The method subsasgn a permits the use of all kinds of assignments to a part of an LTI system If the variable is a matrix of transfer func tions subsasgn produces the expected result converting the right hand side of the assignment to a matrix of transfer function if required If the variable is a state space model the result is equivalent the re sult remains a state space model For state space models changing all the inputs or all the outputs with the syntax var expr sys or var expr sys is much more efficient than specifying both sub scripts or a single index The syntax for field assignment var field value is defined for the following fields for state space models A B C and D matrices of the state space model for transfer functions num and den cell arrays of coefficients for both var string and Ts scalar or empty array for continuous time systems Field assignment must preserve the size of matrices and arrays The syntax with braces var i vaLue is not supported See also ti subsref operator subsasgn Iti s
117. where to search it can be either a starting point or a pair of values xlow and xhigh which must bracket the zero such that fun xlow and fun xhigh have opposite sign The optional third argument may contain options It is either the empty array for the default options or the result of optimset Additional input arguments of fzero are given as additional input arguments to the function specified by fun They permit to parame terize the function Examples Zero of a sine near 3 displayed with 15 digits fprintf 15g n fzero sin 3 3 141592653589793 To find the solution of e c x between 0 and 100 with c 10 a function f whose zero gives the desired solution is written function y f x c y exp x c sqrt x Then fsolve is used with the value of c passed as an additional argu ment x fzero f 0 100 10 X 2 4479 f x 10 1 9984e 15 An anonymous function can be used to avoid passing 10 as an ad ditional argument which can be error prone since a dummy empty option arguments has to be inserted zero x f x 10 0 100 See also 282 LyME User Manual 1999 2008 Calerga Sarl ode23 ode45 Ordinary differential equation integration ode23 ode23 ode23 fun t0 tend y0 te ye ie fun t0 tend y0 options fun t0 tend y0 options ode23 fun t0 tend y0 fun t tend y0 options fun t0 tend y0 options
118. x 0 3 a exp 3x in red for x 2 3 with a 7 2 and an identifier of 1 fun inline function y f x a y x 0 3 2 axexp 3 x 2 fplot fun 2 3 r 7 2 See also hold Graphic freeze Syntax hold on hold off Description Command hold controls whether the graphics window is cleared be fore graphical commands such as plot and text display new ele ments hold on suspends the auto clear feature and hold off re sumes it In any case clf always resumes it LyME functions Example t 0 0 1 2 pi plot t sin t hold on plot t cos t hold off pause 3 plot t sin t cos t See also image Image plot Syntax image A Description 393 image A displays array A as an image A is an array of two dimen sions for grayscale images or three dimensions for RGB images with Size A 3 3 image accepts different types of data double arrays must contain numbers between 0 for black and 1 for maximum in tensity uint8 arrays contain numbers between 0 for black and 255 for maximum intensity and logical arrays contain false for black and true for maximum intensity Function map2int is useful for converting double values in other ranges The image is displayed as a low density bitmap centered in the graphics area The first value in the array corresponds to the top left corner Availability image requires Palm OS 4 0 or higher Example x meshgri
119. y such that x qxy m with integer q Imaginary parts if they exist are ignored Examples mod 10 7 3 mod 10 7 4 mod 10 7 4 mod 10 7 3 See also rem nan Not a Number LME Reference mathematical functions 175 Syntax nan NaN nan n nan n1 n2 nan n1 n2 nan type x X KKK amp tou ot ud ou a Description NaN Not a Number is the result of the primitive floating point func tions or operators called with invalid arguments For example 0 0 inf inf and O inf all result in NaN When used in an expression NaN propagates to the result All comparisons involving NaN result in false except for comparing NaN with any number for inequality which re sults in true Contrary to built in functions usually found in the underlying oper ating system many functions which would result in NaNs give complex numbers when called with arguments in a certain range With integer non negative arguments nan creates arrays whose elements are NaN Arguments are interpreted the same way as zeros and ones The last argument of nan can be a string to specify the type of the result double for double precision default or single for single precision Examples nan nan O nan nan nan nan false nan nan true log 1 0 3 1416j See also nchoosek Binomial coefficient 176 LyME User Manual 1999 2008 Calerga Sarl Syntax b nchoosek n k Description nchoosek
120. 08 Calerga Sarl incremented by 2 The subroutine ends with rts Note that absolute addresses must be avoided only relative jumps must be used An assembler converts this assembly code to the following machine code 72004A40670A3B8010005340544160F24E75 To store this code in a binarydata variable we enter in LyME gt code binarydata 72004A40670A3B8010005340544160F24E75 To execute this code with data initialized to 10 null 16 bit words we use feval gt dataout feval code binarydata zeros 10 1 The result can be converted to a vector of numbers and displayed gt double dataout 10 9 PNW BUI N Words in binary data can also be accessed with subscripts which must be integer values based on 0 In subscript expressions beginning gives 0 the first valid index and end gives the number of words minus one Logical values are not supported gt dataout end 2 end 321 gt dataout 0 2 555 gt dataout 0 5 555 555 555765 3 39 Functions binarydata Create binary code or data Machine code 403 Syntax d binarydata vec d binarydata hexa Description binarydata vec creates a block of binary data from the elements of vector vec converted to words 16 bits values If vec is a vector of class double its elements converted directly to 16 bit words If it is a vector of integer numbers the conversion takes their size into account with the most significant word first for inst
121. 19j 148 LyME User Manual 1999 2008 Calerga Sarl See also cosh Hyperbolic cosine Syntax y cosh x Description cos x gives the hyperbolic cosine of x which is complex if x is com plex Example cosh 0 1 2j 1 0 6421 1 0686j See also sinh jacosh cos cot Cotangent Syntax y cot x Description cot x gives the cotangent of x which is complex if x is See also coth Hyperbolic cotangent LME Reference mathematical functions 149 Syntax y coth x Description coth x gives the hyperbolic cotangent of x which is complex if x is See also tanh csc Cosecant Syntax y csc x Description csc x gives the cosecant of x which is complex if x is See also csch Hyperbolic cosecant Syntax y csch x Description csch x gives the hyperbolic cosecant of x which is complex if x is See also acschi csc sinh 150 LyME User Manual 1999 2008 Calerga Sarl diln Dilogarithm Syntax y diln x Description diln x gives the dilogarithm or Spence s integral of x Argument and result are real imaginary part is discarded The dilogarithm is defined as x log t dinco BC ot tot Example diln 0 2 0 7 10 1 0748 0 3261 3 9507 double Conversion to double precision numbers Syntax B double A Description double A converts number or array A to double precision A can be any kind of numeric valu
122. 2 Example Plot a sine in black and a cosine in light blue t 0 0 1 2 pi plot t sin t cos t kc See also polar Polar plot Syntax polar phi r polar phi r style 396 LyME User Manual 1999 2008 Calerga Sarl Description Command polar displays graphical data in polar coordinates The data are given as two vectors of polar coordinates phi and r their corresponding Cartesian coordinates are x rxcos phi and y r sSin phi Several polar plots may be combined with hold however other kinds of plots should not be mixed If phi and r are matrices each row is considered as a separate line or set of marks Unlike plot both matrices must have the same size See the description of plot for more information about the third argument Example phi 2 pix 0 100 100 polar phi 2 cos 5x phi r See also semilogx Generic plot with a logarithmic scale along x axis Syntax semilogx y semilogx x y semilogx x y style Description Command semilogx is similar to plot except that the scale along the x axis is logarithmic See also semilogy Generic plot with a logarithmic scale along y axis Dialog functions 397 Syntax semilogy y semilogy x y semilogy x y style Description Command semilogy is similar to plot except that the scale along the y axis is logarithmic See also text Display formatted text in a figure Syntax text x y string Descr
123. 234 LyME User Manual 1999 2008 Calerga Sarl cell Cell array of empty arrays Syntax C cell n C cell nl1 n2 C cell n1 n2 Description cell builds a cell array whose elements are empty arrays The size of the cell array is specified by one integer for a square array or several integers either as separate arguments or in a vector for a cell array of any size Example cell 2 3 2x3 cell array See also operator cellfun Function evaluation for each cell of a cell array Syntax A cellfun fun C A cell fun C Description cellfun fun C evaluates function fun for each cell of cell array C Each evaluation must give a scalar result of numeric logical or char acter type results are returned as a non cell array the same size as C First argument is a function reference an inline function or the name of a function as a string With more than two input arguments cellfun calls function fun as feval fun C i other where C i is each cell of C in turn and other stands for the remaining arguments of cellfun LME Reference arrays 235 cellfun differs from map in two ways the result is a non cell array and remaining arguments of cellfun are provided directly to fun Examples cellfun isempty 1 ones 5 FT TF map isempty 1 ones 5 2x2 cell array cellfun size 1 ones 5 2 10 05 See also diag Creation of
124. 4 wn oS ie Ojj e O oO 0 D WwW WwW Ul ot wa SN Ww UJJ ul N UJ UO fee dbstack 71 dbstatus deconv 197 define delaunay delaunayn det 1 diag diff 199 diln disp 341 dlyap dmargin dot 200 double 150 403 O elseif end endfunction 57 eps eq 105 erf erfc 156 erfinv 156 error eval exist 505 factor 158 factorial 158 false 328 fclose 342 feof 342 feval 83 404 fevalx 84 fflush 343 fft 202 fft2 fftn fftshift 415 fgetl fgets 344 fieldnames 313 filestreamingopen 363 filter filter2 415 find 237 findstr 297 fix flipdim fminbnd 277 E fminsearch 279 fop pea for format fplot 391 fprintf 346 fread 346 fscanf 348 fseek 348 ftell fun2str 84 function inline reference function 57 LyME User Manual 1999 2008 Calerga Sarl funm 205 fwrite 349 fzero 280 gamma 1 60 gammainc 160 gammaln gcd ge 105 geomean getfield global 48 goldenratio graycode griddata griddatan gt 105 hankel 415 harmmean 428 hess 208 hist hold 392 horzcat 105 hypot 163 i 163 icdf 164 if B9 if ft 206 ifft2 207 ifftn ifftshift 417 igraycode 330 imag image 393 include includeifexists 61 ind2sub 240 inf 165 info 85 inline
125. 4 2 7424 XI ot N See also dot Scalar product Syntax v3 v3 dot v1 v2 dot v1 v2 dim Description dot v1 v2 gives the scalar products of vectors v1 and v2 v1 and v2 must be row or columns vectors of same length or arrays of the same size then the scalar product is performed along the first dimension not equal to 1 A third argument dim may be used to specify the dimension the scalar product is performed along Examples dot 1 2 3 0 0 1 3 dot 1 2 3 7 1 3 4 0 0 0 2 0 2 4 2 LME Reference linear algebra 201 See also eig Eigenvalues and eigenvectors of a matrix Syntax e eig M V D eig M Description eig M returns the vector of eigenvalues of the square matrix M V D eig M returns a diagonal matrix D of eigenvalues and a matrix V whose columns are the corresponding eigenvectors They are such that M V VD Examples eig 1 2 3 4 0 3723 5 3723 V D eig 1 2 2 1 V 0 7071 0 7071 0 7071 0 7071 D 1 0 03 1 2 2 1 V 0 7071 2 1213 0 7071 2 1213 V xD 0 7071 2 1213 0 7071 2 1213 See also expm Exponential of a square matrix 202 LyME User Manual 1999 2008 Calerga Sarl Syntax M2 expm M1 Description expm M is the exponential of the square matrix M which is usually different from the element wise exponential of M given by exp Examples expm 1 1 1 1 4 1945 3 1945 3 1945 4 1945 exp 1 1 1
126. 5 1 125 1 375 See also ifft Inverse Fast Fourier Transform Syntax f ifft F f ifft F n f ifft F n dim Description ifft returns the inverse Discrete Fourier Transform inverse DFT Up to the sign and a scaling factor the inverse DFT and the DFT are the same operation for a vector ifft d ifft has the same syntax as fft Examples ft 1 2 3 4 See also conj fft d length d LME Reference linear algebra 207 ifft2 Inverse 2 d Fast Fourier Transform Syntax f ifft2 F f ifft2 F size f ifft2 F nr nc f ifft2 F n Description ifft2 returns the inverse 2 d Discrete Fourier Transform inverse DFT along dimensions 1 and 2 With two or three input arguments ifft2 resizes the two first di mensions by cropping or by padding with zeros ifft2 F nr nc re sizes first dimension to nr rows and second dimension to nc columns In ifft2 F size the new size is given as a two element vector nr nc ifft2 F n is equivalent to ifft2 F n n If the first argument is an array with more than two dimensions ifft2 performs the inverse 2 d DFT along dimensions 1 and 2 sepa rately for each plane along remaining dimensions ifftn performs an inverse DFT along each dimension Up to the sign and a scaling factor the inverse 2 d DFT and the 2 d DFT are the same operation ifft2 has the same syntax as See also ifftn Inverse n dimension Fast Fourier Transform Syntax f ifftn F f
127. 5 25e 1 0 25e1 0 25e 1 0 0 0 0 le 99999 inf 1e999999 inf 1e999999 LME Reference 35 Literal integer numbers may also be expressed in hexadecimal with prefix 0x in octal with prefix 0 or in binary with prefix Ob The four literals below all represent 11 stored as double Oxb 013 0b1011 11 Literal integer numbers stored as integers and literal single numbers are followed by a suffix to specify their type such as 2int16 for the number 2 stored as a two byte signed number or 0x300uint32 for the number whose decimal representation is 768 stored as a four byte un signed number All the integer types are valid as well as single This syntax gives the same result as the call to the corresponding function e g 2int16 is the same as int16 2 except when the integer num ber cannot be represented with a double then the number is rounded to the nearest value which can be represented with a double Compare the expressions below Expression Value uint64 123456789012345678 123456789012345696 123456789012345678uint64 123456789012345678 Literal complex numbers are written as the sum or difference of a real number and an imaginary number Literal imaginary numbers are written as double numbers with an i or j suffix like 2i 3 7e5j or Oxffj Functions i and j can also be used when there are no variables of the same name but should be avoided for safety reasons The suffices for single and imaginary can be combined as isingle or js
128. 7e 34 2 17671e 8 1 6726231e 27 6 9599e8 299792458 340 29205 5 67051e 8 8 854187817e 12 LyME User Manual 1999 2008 Calerga Sarl Unit 1 mole J K Vs Am J K mole m 3 mole kg kg Js Js kg kg m m s m s W m 2 K 4 As Vm abs 135 acos 136 acosh 136 acot acoth 137 acsc 138 acsch addpol 188 a eens EOE alawexpand 490 all B21 and 105 angle 139 any PP ea asec asech 139 Ba asin an assert atan atan2 141 atanh 142 R e audioset 400 axis 387 balance bar barh base64decode base64encode beep beginning besselap besself beta betainc 143 betaln 144 bilinear 457 uae a 402 bitall 3 bitand 323 bitany 324 bitcmp bitget bitor 32 bitset 326 bitshift B27 bitxor 328 blkdiag 412 bootstrp 426 break 54 builtin 77 batten faal butter 458 bwrite 340 c2dm 333 cal2julian 370 care 189 cart2pol ca tzeon TT case 54 cast 144 cat 233 catch cdf 145 ceil 146 cell 234 cell array cell2st Pict BIz 312 cell fun 2 char 296 403 circshift class 319 class bitfield int16 452 int32 452 int8 452 uint16 454 uint32 454 uints 454 class bitfield beginning 449 bitfield 449 Toop EST double end 451 find 452 length sign class lti append beginning bodemag bodephase c2d 470 conn
129. 9 2008 Calerga Sarl Example isspace a tb c nd 0101010 See also lower Convert all uppercase letters to lowercase Syntax s2 lower s1 Description lower s1 converts all the uppercase letters of string s1 to lowercase Currently only ASCII letters without diacritic are converted Example Lower abcABC123 abcabc123 See also md5 Calculate MD5 digest Syntax digest md5 strb digest md5 fd LME Reference strings 301 Description md5 strb calculates the MD5 digest of strb which represents binary data strb can be a string only the least significant byte of each character is considered or an array of bytes of class uint8 or ints The result is a string of 32 hexadecimal digits It is believed to be hard to create the input to get a given digest or to create two inputs with the same digest md5 fd calculates the MD5 digest of the bytes read from file de scriptor fd until the end of the file The file is left open MD5 digest is an Internet standard described in RFC 1321 Examples MD5 of the three characters a b and c md5 abc 900150983cd24fb0d6963f7d28e17Ff72 This can be compared to the result of the command tool md5 found on many unix systems echo n abc md5 900150983cd24fb0d6963f7d28e17F72 The following statements calculate the digest of the file somefile fd fopen somefile digest md5 fd fclose fd See also s
130. A returns the polynomial which is the derivative of the poly nomial A Both polynomials are given as vectors of their coefficients highest power first The result is a row vector 222 LyME User Manual 1999 2008 Calerga Sarl With a single output argument polyder A B returns the derivative of the product of polynomials A and B It is equivalent to polyder conv A B With two output arguments N1 D1 polyder N D returns the derivative of the polynomial ratio N D as N1 D1 Input and output ar guments are polynomial coefficients Examples Derivative of x 2x2 5x 4 2 polyder 1 2 5 2 345 Derivative of x 2x 5x 2 2x 3 N N polyder 1 2 5 2 2 3 13 12 11 D fil fil oO 12 9 See also polyint Integral of a polynomial Syntax pol2 polyint poll pol2 polyint poll c Description polyint pol1 returns the polynomial which is the integral of the polynomial poll whose zero order coefficient is 0 Both polynomi als are given as vectors of their coefficients highest power first The result is a row vector A second input argument can be used to specify the integration constant LME Reference linear algebra 223 Example Y polyint 1 2 3 4 5 Y _ 0 2 0 5 1 2 5 0 y polyder Y 1 2 3 4 5 Y polyint 1 2 3 4 5 10 Y 0 2 0 5 1 2 5 10 See also polyval Numerical value of a polynomial evaluated at some point Syntax y polyval pol x
131. Calerga 2 LyME 3 1 User Manual 2 LyME User Manual 1999 2008 Calerga Sarl Copyright 1999 2008 Calerga Sarl No part of this publication may be reproduced transmitted or stored in any form or by any means including electronic mechanical recording or oth erwise without the express written permission of Calerga Sarl The information provided in this manual is for reference and information use only and Calerga assumes no responsibility or liability for any inaccura cies or errors that may appear in this documentation LyME Sysquake LME Calerga the Calerga logo and icons are copyrighted and are protected under the Swiss and international laws Copying this soft ware for any reason beyond archival purposes is a violation of copyright and violators may be subject to civil and criminal penalties LyME Sysquake LME and Calerga are trademarks of Calerga Sarl All other trademarks are the property of their respective owners LyME User Manual August 2008 Yves Piguet Calerga Sarl Lausanne Switzerland Most of the material in LyME User Manual has first been written as a set of XHTML files with lots of cross reference links Since X HTML is not very well suited for printing it has been converted to ATX with the help of a home made conversion utility Additional XML tags have been used to benefit from TEx features e g raster images have been replaced with EPS images equations have been converted from text to real math
132. I object which repre sents a discrete time transfer function with sampling period Ts In both cases num and den may be replaced with cell arrays of coef ficients whose elements are the descending power coefficient vectors The number of rows is the number of system outputs and the number of columns is the number of system inputs An additional argument var may be used to specify the variable of the Laplace s default or p or z transform z default or q tf b6 where b is an LTI object creates a transfer function of the same kind continuous discrete time sampling time and variable as b tf b converts the LTI object b to a transfer function tf gain where gain is a matrix creates a matrix of gains Examples Simple continuous time system with variable p p is used only for dis play use lti sc tf 1 1 2 3 4 p sc continuous time transfer function 1 p 3 2p 2 3p 4 Matrix of discrete time transfer functions for one input and two out puts with a sampling period of 1ms sd tf 0 1 0 15 1 0 8 1 0 78 le 3 sd discrete time transfer function Ts le 3 yl ul 0 1 s 0 8 y2 ul 0 15 s 0 78 See also SS i SS Iti append Append the inputs and outputs of systems Libraries lti 469 Syntax use lti b append al a2 Description append al a2 builds a system with inputs ul u2 and outputs yl y2 where ul and u2 are the inputs of a
133. If Mis an array with multiple dimensions the first two dimensions are permuted ctranspose M is equivalent to M It can be used to redefine this operator for objects LME Reference operators Examples 1 2 3 4 13 24 1 2j 3 4j 1 2j 3 4j See also Operator conj Operator Transpose Syntax M transpose M Description 121 M is the transpose of the matrix M i e columns and rows are per muted M can be real or complex If Mis an array with multiple dimen sions the first two dimensions are permuted transpose M is equivalent to M It can be used to redefine this operator for objects Example 1 2 3 4 13 24 1 2j 3 4j 1 2j 3 4j See also Operator Equality 122 LyME User Manual 1999 2008 Calerga Sarl Syntax x y eq x y Description x y is true if x is equal to y and false otherwise Comparing NaN not a number to any number yields false including to NaN If x and or y is an array the comparison is performed element wise and the result has the same size eq x y is equivalent to x y It can be used to redefine this oper ator for objects Example 1c true 1 1 eps false 1 1 eps 2 true inf inf true nan nan false 1 2 3 1 3 3 TFT See also operator gt operator gt opera Operator Object equality Syntax a same a b LME Reference oper
134. Install at least MathLib prc unless it has already been installed for another application or it is included in the device ROM and LyME prc You can also install library files the files which end with pdb which add more functions to LyME 1 2 Using LyME Launch LyME by tapping its icon Calc Date Book O amp HotSync gus lemo Pod Frets Figure 1 1 6 LyME User Manual 1999 2008 Calerga Sarl Lyme LEDT Rees Gr 2 a pi Sa Figure 1 2 LS ee a ee ii Figure 1 3 Simple expressions Write expressions in the top field tap the Eval button or write return topright to bottomleft Graffiti stroke and read the result in the bot tom field To enter parenthesis or operators you can also tap one of the sym bols at the botton of the screen To enter a function or to check its arguments tap fn and the bottom right of the screen scroll the list and tap the function you want You can also tap outside the list to discard it Previous commands can be retrieved with the arrows at the top left of the screen The command field can be cleared completely with a tap on the C near the arrows An Edit menu is also available for the usual Cut Copy Paste Undo commands tap the window title LyME or the menu button below the screen To stop execution press the Page Down key until the Eval button label is displayed Graphics Some commands produce graphical output Graphics replace the text output below the command field Graph
135. ME Reference logical functions 325 Syntax b bitcmp i b bitcmp a n Description bitcmp i gives the 1 complement bitwise NOT of the integer i bitcmp a n where a is an integer or a double gives the 1 complement of the n least significant bits The result has the same type as a The inputs can be scalar arrays of the same size or a scalar and an array If a is of type double so is the result and the operation is performed on at most 32 bits Examples bitcmp 1 4 14 bitcmp 0 1 8 13 7 15 31 63 127 255 bitcmp Quint8 luint8 255uint8 1x3 uint8 array 255 254 See also bitget Bit extraction Syntax b bitget a n Description bitget a n gives the n th bit of integer a a can be an integer or a double The result has the same type as a n 1 corresponds to the least significant bit The inputs can be scalar arrays of the same size or a scalar and an array If a is of type double so is the result and n is limited to 32 326 LyME User Manual 1999 2008 Calerga Sarl Examples bitget 123 5 1 bitget 7 1 8 11100000 bitget 5uint8 2 Ouints See also bitor Bitwise OR Syntax c bitor a b Description The input arguments are converted to 32 bit unsigned integers each bit of the result is the binary OR of the corresponding bits of the inputs The inputs can be scalar arrays of the same size or a scalar and an array If the input arguments are of type double
136. See also reallog Real natural base e logarithm Syntax y reallog x Description reallog x gives the real natural logarithm of x It is the inverse of exp for real numbers The imaginary part of x is ignored The result is NaN if x is negative Example reallog 1 0 1 10 1 2j nan inf 0 2 3026 0 See also LME Reference mathematical functions realmax realmin Largest and smallest real numbers Syntax realmax realmax n realmax n1 n2 realmax type realmin realmin x X KK KK XK tou wd wt ud ou ou Description realmax nl1 n2 179 realmax gives the largest positive real number in double precision realmin gives the smallest positive real number in double precision which can be represented in normalized form i e with full mantissa precision With integer non negative arguments realmax and realmin create arrays whose elements are all set to the respective value Arguments are interpreted the same way as zeros and ones The last argument of realmax and realmin can be a string to spec ify the type of the result double for double precision default or single for single precision Examples realmin 2 2251e 308 realmin single 1 1755e 38 realmax 1 7977e308 realmax single 3 4028e38single realmax eps realmax inf See also realpow Real power 180 LyME User Manual 1999 2008 Calerga Sarl Syntax z real
137. Syntax C num2cell A C num2cell A dims Description num2cell A creates a cell array the same size as numeric array A The value of each cell is the corresponding elements of A num2cell A dims cuts array A along dimensions dims and creates a cell array with the result Dimensions of cell array are the same as dimensions of A for dimensions not in dims and 1 for dimensions in dims dimensions of cells are the same as dimensions of A for dimen sions in dims and 1 for dimensions not in dims Argument A can be a numerical array of any dimension and class a logical array or a char array Examples num2cell 1 2 3 4 1 2 3 4 num2cell 1 2 3 4 1 1 3 2 4 num2cell 1 2 3 4 2 1 2 3 4 See also 252 LyME User Manual 1999 2008 Calerga Sarl numel Number of elements of an array Syntax n numel A Description numel A gives the number of elements of array A It is equivalent to prod size A Examples numel 1 5 5 numel ones 2 3 6 numel 1 1 6 abc 4 numel 2 vwxyz 2 See also length ones Array of ones Syntax A ones n A ones n1 n2 A ones n1 n2 A ones type Description ones builds an array whose elements are 1 The size of the array is specified by one integer for a square matrix or several integers either as separate arguments or in a vector for an array of any size An additional in
138. Syntax phi angle z Description angle z gives the phase of the complex number z i e the angle be tween the positive real axis and a line joining the origin to z angle 0 is O Examples angle 1 3j 1 2490 angle 0 1 1 0 0 3 1416 See also asec Inverse secant Syntax y asec x Description asec x gives the inverse secant of x which is complex if x is complex or is in the range 1 1 See also asech Inverse hyperbolic secant 140 LyME User Manual 1999 2008 Calerga Sarl Syntax y asech x Description asech x gives the inverse hyperbolic secant of x which is complex if x is complex or strictly negative See also asec asin Arc sine Syntax y asin x Description asin x gives the arc sine of x which is complex if x is complex or if abs x gt 1 Examples asin 5 0 5236 asin 2 1 5708 1 317j See also asinh Inverse hyperbolic sine Syntax y asinh x LME Reference mathematical functions 141 Description asinh x gives the inverse hyperbolic sine of x which is complex if x is complex Examples asinh 2 1 4436 asinh 0 1 2j 0 1 8055 1 7359j See also atan Arc tangent Syntax y atan x Description atan x gives the arc tangent of x which is complex if x is complex Example atan 1 0 7854 See also atan2 Direction of a point given by its Cartesian coordinates Syntax phi atan2 y x 142 LyME Us
139. also gammalin Logarithm of gamma function Syntax y gammatn x Description gammaln x gives the logarithm of the gamma function of x Argument and result are real imaginary part is discarded gammaln does not rely on the computation of the gamma function to avoid overflows for large numbers Examples gammaln 1000 5905 2204 gamma 1000 inf 162 LyME User Manual 1999 2008 Calerga Sarl See also gammainc gcd Greatest common divisor Syntax q gcd a b Description gcd a b gives the greatest common divisor of integer numbers a and b Example gcd 72 56 8 See also goldenratio Golden ratio constant Syntax x goldenratio Description goldenratio is the golden ration v5 1 2 up to the precision of its floating point representation Example goldenratio 1 6180 LME Reference mathematical functions 163 See also hypot Hypotenuse Syntax c hypot a b Description hypot a b gives the square root of the square of a and b or of their absolute value if they are complex The result is always real hypot avoids overflow when the result itself does not overflow Examples hypot 3 4 5 hypot 1 2 3 4j inf 5 5 099 5 3852 5 831 inf See also ij Imaginary unit Syntax i j 1 23e41 1 23e4j 164 LyME User Manual 1999 2008 Calerga Sarl Description i or j are the imaginary unit i e the pure imaginary number whose square is
140. an inf TTFF See also isfloat Test for a floating point object Syntax b isfloat x Description 167 isfloat x is true if the input argument is a floating point type dou ble or single and false otherwise Examples isfloat 2 true isfloat 2int32 false See also isinf Test for infinity Syntax b isinf x Description isinf x is true if the input argument is infinite neither finite nor nan and false otherwise The result is performed on each element of the input argument and the result has the same size 168 LyME User Manual 1999 2008 Calerga Sarl Example isinf 0 1 nan inf FF FT See also isinteger Test for an integer object Syntax b isinteger x Description isinteger x is true if the input argument is an integer type includ ing char and logical and false otherwise Examples isinteger 2int16 true isinteger false true isinteger abc true isinteger 3 false See also isnan Test for Not a Number Syntax b isnan x LME Reference mathematical functions 169 Description isnan x is true if the input argument is nan not a number and false otherwise The result is performed on each element of the input argument and the result has the same size Example isnan 0 1 nan inf FFTF See also isnumeric Test for a numeric object Syntax b isnumeric x Description isnumeric x is true if the in
141. ance binarydata uint8 0 0 1 0 binarydata int16 0 256 and binarydata uint32 256 all produce the same binary data containing the 16 bit words 0 and 256 binarydata str creates a block of binary data whose value is given by the string of hexadecimal digits str The length of str must be a multiple of 4 so that the block has an integer number of words See also char Convert binary data to a string of characters Syntax str char d Description char d converts binary data to a a string of characters Each char acter corresponds to one byte See also double Convert binary data to a vector of double 404 LyME User Manual 1999 2008 Calerga Sarl Syntax vec double d Description double d converts binary data to a column vector of double num bers See also feval Call machine language in binary data Syntax feval code dataout feval code datain Description feval code calls code in binary data code with the following instruc tions movea 0 a5 clr w dQ jsr code feval code data calls code in binary data code with the following instructions lea data a5 move l dataSize d0 jsr code The binary data data possibly modified is returned In both cases the code should be a subroutine and end with rts Warning feval has the potential of crashing LyME if its arguments do not cor respond to valid code and data Machine code 405 See also Dinarydata pcena
142. and of xi and yi must be equal The result is an array with the same size as Xi and yi where each element is the row index in t of the first triangle which contains the point or NaN if the point is outside all triangles i e outside the convex hull of points defined by x and y if t is a proper triangulation such as the one computed with delaunay Example Search for triangles containing points 0 0 and 0 1 corresponding to Delauny triangulation of 20 random points x randn 20 1 y randn 20 1 t delaunay x y xi 0 0 yi 0 1 ix tsearch x y t xi yi See also tsearchn delaunay voronoi tsearchn Search of points in triangulation simplices Syntax ix tsearchn x t xi Description tsearchn x t xi searches in which simplex each point given by the rows of array xi is located Rows of array x represent the vertices of the simplices and rows of array t represent their indices in x array t 272 LyME User Manual 1999 2008 Calerga Sarl is usually the result of deLaunayn Dimensions must match in a space of n dimensions x and xi have ncolumns and t has n 1 columns The result is a column vector with one element for each row of xi which is the row index in t of the first simplex which contains the point or NaN if the point is outside all simplices i e outside the convex hull of points x if t is a proper triangulation of x such as the one computed with delaunayn Example Se
143. and line interface with dbquit See also dbstop dbcont dbhalt dbstack Chain of function calls Syntax dbstack s dbstack dbstack all s dbstack all Description dbstack displays the chain of function calls which lead to the current execution point with the line number where the call to the subfunction is made It can be executed in a function or from the command line interface when execution is suspended with a breakpoint or dbhalt dbstack all or dbstack all displays the whole stack of function calls For instance if two executions are successively suspended at breakpoints dbstack displays only the second chain of function calls while dbstack all displays all functions With an output argument dbstack returns the result as a structure array Field name contains the function name or class and method names and field Line the line number Note that you cannot assign the result of dbstack to a new variable in suspended mode Examples use stat dbstop prctile igr rand 1 1000 lt prctile 45 gt if nargin lt 3 dbstack stat prctile 45 stat iqr 69 72 LyME User Manual 1999 2008 Calerga Sarl See also dbstatus Display list of breakpoints Syntax dbstatus dbstatus fun Description dbstatus displays the list of all breakpoints dbstatus fun displays the list of breakpoints in function fun See also dbstop dbtype dbstep Execute a line of instructions Syntax
144. aracter arrays The basic type of LME is the two dimensional array or matrix Scalar numbers and row or column vectors are special kinds of matrices Ar rays with more than two dimensions are also supported All elements have the same type which are described in the table below Two non numerical types exist for character arrays and logical boolean arrays Cell arrays which contain composite types are described in a section below LME Reference Type double complex double single complex single uint32 int32 uint16 int16 uint8 int8 uint64 int64 33 Description 64 bit IEEE number Two 64 bit IEEE numbers 32 bit IEEE number Two 32 bit IEEE numbers 32 bit unsigned integer 32 bit signed integer 16 bit unsigned integer 16 bit signed integer 8 bit unsigned integer 8 bit signed integer 64 bit unsigned integer 64 bit signed integer 64 bit integer numbers are not supported by all applications on all platforms These basic types can be used to represent many mathematic ob jects Scalar One by one matrix Vector n by one or one by n matrix Functions which return vec tors usually give a column vector i e n by one Empty object 0 by 0 matrix 0 by n or n by 0 matrices are always converted to 0 by 0 matrices Polynomial of degree d 1 by d 1 vector containing the coeffi cients of the polynomial of degree d highest power first List of n polynomials of same degree d n by d 1 matrix con taining th
145. arch for simplices containing points 0 0 and 0 1 corresponding to Delauny triangulation of 20 random points randn 20 2 delaunayn x 0 0 0 1 tsearchn x t xi x t xi ix See also delaunayn voronoin voronoi 2 d Voronoi tessalation Syntax v p voronoi x y Description voronoi x y calculates the Voronoi tessalation of the set of 2 d points given by arrays x and y Both arrays must have the same number of values m The first output argument v is an array of two columns which contains the coordinates of the vertices of the Voronoi cells one row per vertex The first row contains infinity and is used as a marker for unbounded Voronoi cells The second output argument p is a list of vectors of row indices in v each element describes the Voronoi cell corresponding to a point in x In each cell vertices are sorted counterclockwise Voronoi tessalation is a tessalation a partition of the plane such that each region is the set of points closer to one of the initial point than to any other one Two regions are in contact if and only if their initial points are linked in the corresponding Delaunay triangulation LME Reference triangulation 273 Example Voronoi tessalation of 20 random points x rand 20 1 y rand 20 1 v p voronoi x y These points are displayed as crosses with Sysquake graphical func tions The scale is fixed because Voronoi polygons can have vertices
146. argument obj is a structure or structure array false otherwise Examples isstruct struct a 123 true isstruct 1 2 x false a f 3 isstruct a true See also orderfields Reorders the fields of a structure Syntax strctout orderfields strctin strctout orderfields strctin structref strctout orderfields strctin names strctout orderfields strctin perm strctout perm orderfields Description With a single input argument orderfields strctin reorders struc ture fields by sorting them by field names With two input arguments orderfields reorders the fields of the first argument after the second argument Second argument can be a permutation vector containing integers from 1 to Llength strctin another structure with the same field names or a list of names In the last cases all the fields of the structure must be present in the second argument 316 LyME User Manual 1999 2008 Calerga Sarl The first output argument is a structure with the same fields and the same value as the first input argument the only difference is the field order An optional second output argument is set to the permu tation vector Examples s struct a 123 c 1 3 b 123 7 a 123 c real 1x3 b abcde t p orderfields s t a 123 b abcde c real 1x3 p 1 3 2 t orderfields s c b a t c real 1x3 b abcd
147. ary that can be used by any OS 2 0 Pilot program that needs IEEE 754 double precision math functions It is distributed under the terms of the GNU Library General Public License and is freely available with full source code and documentation at the MathLib Information web page It is not a part of the LyME program and you re not paying anything for its use a copy is simply included in this archive for your convenience Thanks Rick Chapter 2 LME Tutorial The remainder of this chapter introduces LME TM Lightweight Math Engine the interpreter for numerical computing used by Sysquake and shows you how to perform basic computations It supposes you can type commands to a command line interface You are invited to type the examples as you read this tutorial and to experiment on your own For a more systematic description of LME please consult the LME Reference chapter In the examples below we assume that LME displays a prompt gt This is not the case for all applications You should never type it your self Enter what follows the prompt on the same line hit the Return key or tap the Eval or Execute button and observe the result 2 1 Simple operations LME interprets what you type at the command prompt and displays the result unless you end the command with a semicolon Simple ex pressions follow the syntactic rules of many programming languages gt 2 3 4 ans 14 gt 2 3 4 ans 2 75 As you can see the evaluat
148. ation error is propagated outside the sandbox sandbox try fd fopen etc passwd end Security violation fopen See also sandboxtrust eval LME Reference operators 103 sandboxtrust Escape the sandbox restrictions Syntax sandboxtrust fun Description sandboxtrust fun sets a flag associated with function fun so that fun is executed without restriction even when called from a sandbox All functions called directly or indirectly from a trusted function are executed without restriction except if a nested call to sandbox is per formed Argument fun can be a function reference or the name of a function as a string the function must be a user function not a built in one The purpose of sandboxtrust is to give back some of the capabili ties of unrestricted code to code executed in a sandbox For instance if unsecure code must be able to read the contents of a specific file a trusted function should be written for that It is very important for the trusted function to check carefully its arguments such as file paths or URL Example Function which reads the contents of file data txt function data readFile fd fopen data txt data fread fd inf x char fclose fd Execution of unsecure code which may read this file sandboxtrust readFile sandbox d readFile See also sandbox 3 12 Operators Operators are special functions with a syntax which mimic
149. ative LME floating point number Longint str creates a long integer from a string of decimal digits Examples Longint 1234567890 1234567890 Longint 2 100 1267650600228229401496703205376 13th Mersenne prime Longint 2 521 1 6864797660130609714981900799081393217269 4353001433054093944634591855431833976560 5212255964066145455497729631139148085803 7121987999716643812574028291115057151 LyME functions 387 Number of decimal digits in the 27th Mersenne prime Length char longint 2 44497 1 13395 3 34 LyME Functions axis Set the scale of the next graphics Syntax axis xmin xmax ymin ymax axis equal limits axis Description With an input argument the axis command which should be placed before any other graphical command sets the scale and scale options The parameter is either a vector of 4 elements which sets the limits of the plot for both x and y axis or the string equal to make the scale equal in both directions so that circles are really displayed as circles and not ellipses With an output argument axis gives the current limits of the plot in a row vector xmin xmax ymin ymax See also ctf hota bar Vertical bar plot Syntax kind bar x y w kind color 388 LyME User Manual 1999 2008 Calerga Sarl Description bar x y plots the columns of y as vertical bars centered around the corresponding value in x If x is not speci
150. ator conj Operator Matrix multiplication Syntax xX y M1 x M2 M x mtimes x y Description xxy multiplies the operands together Operands can be scalars plain arithmetic product matrices matrix product or mixed scalar and matrix LME Reference operators 115 mtimes x y is equivalent to x y It can be used to redefine this operator for objects Example 2 3 6 1 2 3 4 3 5 See also Operator Scalar multiplication Syntax xX y M1 M2 M xX times x y Description x y is the element wise multiplication If both operands are matrices with a size different from 1 by 1 their size must be equal the mul tiplication is performed element wise If one operand is a scalar it multiplies each element of the other operand times x y is equivalent to x y It can be used to redefine this operator for objects Example 1 2 3 5 3 10 3 4 2 6 8 116 LyME User Manual 1999 2008 Calerga Sarl See also Operator Matrix right division Syntax b B b div rdivide a b Description a b divides the first operand by the second operand If the second operand is a scalar it divides each element of the first operand If the second operand is Otherwise it must be a square matrix M1 M2 is equivalent to M1 inv M2 mrdivide x y is equivalent to x y It can be used to redefine this operator for objects Example 9 3 3 2 6
151. ators 123 Description a bis true if ais the same as b and false otherwise a and b must have exactly the same internal representation to be considered as equal with IEEE floating point numbers nan nan is true and 0 0 is false Contrary to the equality operator returns a single boolean even if its operands are arrays same a b is equivalent to a b Example 1 5 1 5 true 1 5 1 5 TTTTT 1 2 3 4 5 false 1 2 3 4 5 Incompatible size nan nan true nan nan false See also Operator Inequality Syntax Description x y is true if x is not equal to y and false otherwise Comparing NaN not a number to any number yields true including to NaN If x and or y is an array the comparison is performed element wise and the result has the same size ne x y is equivalent to x y It can be used to redefine this oper ator for objects 124 LyME User Manual 1999 2008 Calerga Sarl Example 1 1 false inf inf false nan nan true 1 2 3 1 3 3 FTF See also Operator gt operator gt joper Operator Object inequality Syntax a unsame a b Description a b is true if a is not the same as b and false otherwise a and b must have exactly the same internal representation to be considered as equal with IEEE numbers nan nan is false and 0 0 is true Contrary to the inequality operator
152. ax name list serialdevname n serialdevname Description serialdevname n returns the name of the n th serial device which can be opened by serialdevopen Argument n must be 1 or higher with other values such as those larger than the number of serial de vices available on your computer serialdevname returns the empty string Without input argument serialdevname gives the list of serial de vice names Examples On a Macintosh with internal modem serialdevname 1 Internal Modem Under Windows serialdevname 1 COM1 See also serialdevopen serialdevopen Open a serial port Syntax fd fd serialdevopen portname options serialdevopen portname 384 LyME User Manual 1999 2008 Calerga Sarl Description serialdevopen portname opens a connection to the serial port whose name is portname and returns a file descriptor fd Names depend on the operating system and can be obtained with serialdevname Some platforms do not provide a complete list of all ports serialdevopen may accept additional device names and pass them directly to the corresponding function of the operating system The second argument of serialdevopen portname options isa structure which contains configuration settings It is set with serialdevset Once a connection has been opened the file descriptor fd can be used with functions such as fread fwrite fscanf and fprintf The connection is closed with fclose Example fd se
153. ax q lcm a b Description lcm a b gives the least common multiple of integer numbers a and b 172 LyME User Manual 1999 2008 Calerga Sarl Example lcm 72 56 504 See also gcd log Natural base e logarithm Syntax y log x Description log x gives the natural logarithm of x It is the inverse of exp The result is complex if x is not real positive Example log 1 0 1 10 1 2j 0 3 1416j inf 0 2 3026 0 8047 1 1071j See also log10 Decimal logarithm Syntax y logl10 x Description log10 x gives the decimal logarithm of x defined by log10 x log x log 10 The result is complex if x is not real positive LME Reference mathematical functions 173 Example log10 1 0 1 10 1 2j 0 1 3644j inf 1 0 3495 0 4808j See also logip Logarithm of x plus one Syntax y loglp x Description loglp x is lLog 1 x with improved precision for small x Example loglp 1e 15 le 15 log 1 1e 15 1 1102e 15 See also log2 Base 2 logarithm Syntax y log2 x Description log2 x gives the base 2 logarithm of x defined as log2 x log x log 2 The result is complex if x is not real positive 174 LyME User Manual 1999 2008 Calerga Sarl Example log2 1 2 1024 2000 5 0 1 10 10 9658 2 3219 4 5324j See also mod Modulo Syntax m mod x y Description mod x y gives the modulo of x divided by y i e a number m between O and
154. ax use lti b isct a Description isct a is true if system a is continuous time or static and false oth erwise See also isdt Test for a discrete time LTI Syntax use lti b isdt a Description isdt a is true if system a is discrete time or static and false other wise See also isct Iti isempty Test for an LTI without input output 476 LyME User Manual 1999 2008 Calerga Sarl Syntax use lti b isempty a Description isempty a is true if system a has no input and or no output and false otherwise See also Lti sizel lti issiso Iti isproper Test for a proper causal LTI Syntax use lti b isproper a Description isproper a is true if lti object a is causal or false otherwise An ss object is always causal A tf object is causal if all the transfer functions are proper i e if the degrees of the denominators are at least as large as the degrees of the numerators Iti issiso Test for a single input single output LTI Syntax use lti b issiso a Description issiso a is true if lti object a has one input and one output single input single output system or SISO or false otherwise Uti sizel lti isempty Libraries lti 477 Iti minreal Minimum realization Syntax use lti b minreal a b minreal a tol Description minreal a modifies lti object a in order to remove states which are not controllable and or not observable For tf objects i
155. ax ymin ymax the samples are at equidistant points between xmin and xmax in the x direction and between ymin and ymax in the y direction The optional third argument levels if non empty gives the number of contour lines if it is a scalar or the levels themselves if it is a vector LyME functions 391 contour Figure 3 5 Example of contour Example A function is evaluated over a grid of two variables x and y and is drawn with contour see Fig 3 5 x y meshgrid 2 0 40 10 z exp x 0 2 2 y 3 2 exp x 0 5 2 y 0 1 2 0 1 x axis equal contour z 1 1 1 1 See also fplot Function plot Syntax fplot fplot fplot fplot fun fun limits fun limits style fun limits style pl p2 Ne 392 LyME User Manual 1999 2008 Calerga Sarl Description Command fplot fun limits plots function fun specified by its name as a string a function reference or an inline function The function is plotted for x between Limit 1 and Limit 2 the default limits are 5 5 The style of the plot can be specified with a third argument see plot for details Remaining input arguments of fplot if any are given as additional input arguments to function fun They permit to parameterize the function For example fplot fun 0 10 2 5 calls fun as y fun x 2 5 and displays its value for x between 0 and 10 Examples Plot a sine fplot sin Plot
156. axIter 500 TolX Display of the steps performed to find the zero of cosx between 1 and 2 fzero cos 1 2 optimset Display true Checking lower bound Checking upper bound Inverse quadratic interpolation 2 1 5649 1 Inverse quadratic interpolation 1 5649 1 571 2 Inverse quadratic interpolation 1 571 1 5708 1 5649 Inverse quadratic interpolation 1 5708 1 5708 1 571 Inverse quadratic interpolation 1 5708 1 5708 1 571 ans 1 5708 See also quad Numerical integration 294 LyME User Manual 1999 2008 Calerga Sarl Syntax y quad fun a b y quad fun a b tol y quad fun a b tol trace y quad fun a b tol trace Description quad fun a b integrates numerically function fun between a and b fun is either specified by its name or given as an anonymous or inline function or a function reference The optional fourth argument is the requested relative tolerance of the result It is either a positive real scalar number or the empty ma trix or missing argument for the default value which is sqrt eps The optional fifth argument if true or nonzero makes quad displays information at each step Additional input arguments of quad are given as additional input arguments to function fun They permit to parameterize the function Example 2 te tdt 0 quad t t xexp t 0 2 0 5940 See also 3 19 String Functions base64decode Decode base64 encoded data Syntax strb
157. base64decode strt LME Reference strings 295 Description base64decode strt decodes the contents of string strt which rep resents data encoded with base64 Characters which are not A Z a 2 0 9 or are ignored Decoding stops at the end of the string or when is reached See also baseo4encode base64encode Encode data using base64 Syntax strt base64encode strb Description base64encode strb encodes the contents of string strb which rep resents binary data The result contains only characters A Z a 2 0 9 and it is suitable for transmission or storage on media which accept only text Each character of encoded data represents 6 bits of binary data i e one needs four characters for three bytes The six bits represent 64 different values encoded with the characters A to Z a to z 0 to 9 and in this order When the binary data have a length which is not a multiple of 3 encoded data are padded with one or two characters to have a multiple of 4 Base64 encoding is an Internet standard described in RFC 1521 Example s base64encode char 0 10 S AAECAWQFBgcICQo double base64decode s 0 12 3 4 5 67 8 9 10 See also base64decode 296 LyME User Manual 1999 2008 Calerga Sarl char Convert an array to a character array string
158. but otherwise is present the statements following otherwise are executed If the switch expression yields a string a match occurs only in case of equality with a case string ex pression or any element of a case list expression 66 LyME User Manual 1999 2008 Calerga Sarl Example switch option case arithmetic m mean data case geometric m prod data 1 length data otherwise error unknown option end See also try Error recovery Syntax try end try catch end Description The statements after try are executed If an error occurs execution is switched to the statements following try if any or to the statements following end The error message can be retrieved with lasterr or lasterror If no error occurs the statements between try and end are ignored try ignores two errors the interrupt key Control Break on Windows Command on Mac OS X Control C on other operating systems with a keyboard timeout in Sysquake Remote an attempt to execute an untrusted function in a sandbox The error can be handled only outside the sandbox LME Reference programming constructs Examples a l a 2 555 Index out of range try a 2 end 555 555 try a 2 catch 333 end 555 333 555 try a catch 333 end 555 a Ian a Ue il 55 See also until End of repeat until loop See also use Import libraries Syntax use lib use libl lib2 Descripti
159. c 3 ct Y c NN OS NNO r ap c OornrtOoOUrR O UF ONO LME Reference arrays 265 See also tril diag union Set union Syntax c union a b c ia ib union a b Description union a b gives the union of sets a and b i e it gives the set of members of sets a or b or both Sets are any type of numerical char acter or logical arrays or lists or cell arrays of character strings Mul tiple elements of input arguments are considered as single members the result is always sorted and has unique elements The optional second and third output arguments are vectors of in dices such that if c ia ib union a b then elements of c are the elements of a ia or b ib the intersection of a ia and b ib is empty Example a a bc bbb de b z bc aa bbb c ia ib union a b c a aa bbb bc de z ia 1324 ib 31 a ia a bbb bc de b ib aa z Set exclusive or can also be computed as the union of a and b minus the intersection of a and b setdiff union a b intersect a b a aa de z 266 LyME User Manual 1999 2008 Calerga Sarl See also setditt unique Keep unique elements Syntax v2 unique v1 list2 unique list1 b ia ib unique a Description With an array argument unique
160. cancel 1 5 License LyME and its documentation Copyright 1997 2008 Calerga All rights reserved LyME may not be redistributed without the prior written permission of Calerga The user assumes all the risks caused by the use of LyME and the results obtained with LyME Under no circumstance will Calerga its emplyees or resellers be responsible for any loss of money time data goods or lives 14 LyME User Manual 1999 2008 Calerga Sarl 1 6 What s more in Sysquake While it is based on the same computation engine and language Sysquake has a completely different graphical system whose goal is nearly instantaneous interactivity with the mouse This interactivity opens a new dimension effect of parametric variations relationships between different figures etc and permits the user to get an intuitive understanding of his her problems and to solve them more efficiently Sysquake also has file support extensions large high quality numeri cal libraries a user interface which supports many more options print support and a lot of other features LyME runs on much slower hardware typically 1000 times slower it is useful for small to medium size problems and is located some where between high end scientific calculators and desktop numeric software such as Matlab with which it is largely compatible For more information about Sysquake and LyME please visit http www calerga com 1 7 MathLib MathLib is a free shared libr
161. cle gm psi wc wx dmargin 0 05 poly 0 9 0 9 gm 0 2 3 8 psi 0 7105 wc 0 0 4510 wx 0 2112 Unstable closed loop gm psi wc wx dmargin 1 poly 0 9 0 9 gm psi Caveats Contrary to many functions dmargin cannot be used with several transfer functions simultaneously because not all of them may cor respond simultaneously to either stable or unstable closed loop sys tems See also margin Robustness margins of a continuous time system Syntax gm psi wc wx margin num den Description The open loop continuous time transfer function is given by the two polynomials num and den If the closed loop system with negative feedback is unstable all output arguments are set to an empty ma trix Otherwise margin calculates the gain margins gm which give the 338 LyME User Manual 1999 2008 Calerga Sarl interval of gain for which the closed loop system remains stable the phase margin psi always positive if it exists which defines the sym metric range of phases which can be added to the open loop system while keeping the closed loop system stable the critical frequency as sociated to the gain margins where the open loop frequency response intersects the real axis around 1 and the cross over frequency asso ciated to the phase margin where the open loop frequency response has a unit magnitude If the Nyquist diagram does not cross the unit circle psi and wx are empty Exampl
162. cond argument is the new position The third argument mode specifies how the posi tion is used b absolute position from the beginning of the file c relative position from the current position e offset from the end of the file must be lt 0 The default value is b Only the first character is checked so beginning is a valid alternative for b fseek returns 0 if success ful or 1 if the position is outside the limits of the file contents See also ftell Get the current read or write position in a file Syntax position ftell fd Description ftell fd gives the current file position associated with file descriptor fd The file position is the offset with respect to the beginning of the file at which the next input function will read or the next output function will write The offset is expressed in bytes With text files ftell may not always correspond to the number of characters read or written See also fseek feof fwrite Raw output 350 LyME User Manual 1999 2008 Calerga Sarl Syntax count fwrite fd data count fwrite fd data precision Description fwrite fd data writes the contents of the matrix data to the out put referenced by the file descriptor fd The third parameter is the precision whose meaning is the same as for fread Its default value is 7uint8 See also redirect Redirect or copy standard output or error to another file descriptor Syntax redir
163. ction can provide is an error LME Reference variables 47 Variables can store any kind of contents dynamically the size and type can change from assignment to assignment A subpart of a matrix variable can be replaced with the use of In this case the size of the variable is expanded when required padding elements are 0 for numeric arrays and empty ar rays for cell arrays and lists See also beginning First index of an array Syntax v beginning A beginning function e C beginning obj i n Description In an expression used as an index to access some elements of an array beginning gives the index of the first element line or column depending of the context It is always 1 for native arrays beginning can be overloaded for objects of used defined classes Its definition should be have a header equivalent to function e C beginning obj i n where C is the name of the class obj is the object to be indexed i is the position of the index expression where beginning is used and n is the total number of index expressions See also Operator 0 operator 1 end Last index of an array 48 LyME User Manual 1999 2008 Calerga Sarl Syntax v end A end function e C end obj i n Description In an expression used as an index to access some elements of an ar ray end gives the index of the last element line or column depending of the context end can be over
164. d for descending order In both cases NaNs are moved to the end sort list sorts the elements of a list which must be strings Cell arrays are sorted like lists not column wise like numeric arrays The second output argument is a row vector The direction can be specified with a second input argument Examples sort 3 6 2 3 9 1 2 1223369 sort 2 5 3 nan 4 2 6 1 1 2 1 1 6 4 2 nan 5 3 sort 2 5 3 nan 4 2 6 1 1 d 6 5 3 2 4 2 nan 1 1 sort def abcd abc abc abcd def To sort the rows of an array after the first column one can obtain the permutation vector by sorting the first column and use it as subscripts on the array rows M 2 4 5 1 3 9 4 0 2 4 5 1 39 40 Ms ix sort M 1 M ix 262 LyME User Manual 1999 2008 Calerga Sarl Algorithm Shell sort See also squeeze Suppression of singleton dimensions of an array Syntax B squeeze A Description squeeze A returns an array with the same elements as A but where dimensions equal to 1 are removed The result has at least 2 dimen sions row and column vectors keep their dimensions Examples size squeeze rand 1 2 3 1 4 234 size squeeze 1 5 15 See also sub2ind Conversion from row column subscripts to single index Syntax ind sub2ind size i j LME Reference arrays 263 Description sub2ind size i j gives the single index which can b
165. d s returns the empty array as output argument To discard it the statement should be followed by a semicolon rand n rand nl1 n2 and rand nl n2 return an n by n square matrix or an array of arbitrary size whose elements are pseudo random numbers uniformly distributed between 0 and 1 Examples rand 0 2361 rand 1 3 0 6679 0 8195 0 2786 rand seed Q rand 0 2361 See also randn randn Normally distributed random number Syntax x randn M randn n M randn nl1 n2 M randn nl1 n2 randn seed s LME Reference arrays 255 Description randn builds a scalar pseudo random number chosen from a normal distribution with zero mean and unit variance The current imple mentation is based on a scalar 64 bit seed which theoretically al lows 2 64 different numbers This seed can be set with the arguments randn seed s wheres is a scalar or a vector of two components The seed is not the same as the seed of rand randn seed s re turns the empty array as output argument To discard it the state ment should be followed by a semicolon randn n randn n1 n2 and randn n1 n2 return an n by n square matrix or an array of arbitrary size whose elements are pseudo random numbers chosen from a normal distribution Examples randn 1 5927 randn 1 3 0 7856 0 6489 0 8141 randn seed 0 randn 1 5927 See also rand repmat
166. d c2dm 1 1 1 0 1 numd 0 0952 dend 1 0 9048 numd dend c2dm 1 1 1 0 1 foh numd 0 0484 dend 1 0 9048 numd dend c2dm 1 1 1 0 1 tustin numd 0 0476 0 0476 dend 1 0 9048 LME Reference dynamical systems 335 See also d2cm Discrete to continuous time conversion Syntax numc denc d2cm numd dend Ts denc d2cm numd dend Ts numc denc d2cm numd dend Ts method denc d2cm numd dend Ts method Description numc denc d2cm numd dend Ts method converts the discrete time transfer function numd dend with sampling period Ts to a continuous time transfer function numc denc The continuous time transfer function is given by two polynomials in s and the discrete time transfer function is given by two polynomials in z all as vectors of coefficients with highest powers first Method is tustinor t Tustin bilinear transformation default The input and output arguments numc denc numd and dend can also be matrices in that case the conversion is applied separately on each row with the same sampling period Ts d2cm Ad Bd Cd Dd Ts method performs the conversion from discrete time state space model Ad Bd Cd Dd to continuous time state space model Ac Bc Cc Dc defined by x kK 1 Agx k Bgu k y k Cygx k Dgu k and dx art Acx t Bcu t y t C x t D u t 336 LyME User Manual 1999 2008 Calerga Sarl Example numd dend
167. d 2 0 1 2 A cos x 2 x 2 image map2int A 1 1 coord for x y is x cos r 2 element wise double 1 1 to uint8 394 LyME User Manual 1999 2008 Calerga Sarl See also loglog Generic plot with a logarithmic scale along x and y axis Syntax loglog y loglog x y loglog x y style Description Command loglog is similar to plot except that the scale along both x and y axis is logarithmic See also pause Put the handheld in low power mode Syntax pause t Description pause t makes the handheld wait for t seconds in low power mode plot Generic plot Syntax plot y plot x y plot x y style LyME functions 395 Description Command plot displays graphical data The data are given as two vectors of coordinates x and y Depending on the style the points are displayed as individual marks style x o or or are linked with lines style The style may also specify the color Color Character black blue green cyan red magenta yellow white lt 3S500Q07R r The default style is If x and y are matrices each row is considered as a separate line or set of marks if only one of them is a matrix the other one a vector is reused for each line The style string may contain several styles which are used for each line and recycled if necessary The first argument x may be omitted its default value is l size y
168. d by the columns of A and B Examples Angle between two vectors in R 2 Libraries stdlib 425 use stdlib a 3 2 b 1 5 subspace a b 0 7854 Angle between the vector 1 1 1 and the plane spanned by 2 5 3 and 7 1 0 in R 3 subspace 1 1 1 2 7 5 1 3 0 0 2226 toeplitz Toeplitz matrix Syntax use stdlib X toeplitz c r X toeplitz c Description toeplitz c r creates a Toeplitz matrix whose first column contains the elements of vector c and whose first row contains the elements of vector r A Toeplitz matrix is a matrix whose diagonals have the same value In case of conflict the first element of r is ignored With one argument toeplitz gives a symmetric square matrix Example use stdlib toeplitz 1 1 2 3 1 5 4 5 3 4 2 3 PN WA 2 1 3 2 See also hankel diag trapz Numerical integration with trapezoidal approximation 426 LyME User Manual 1999 2008 Calerga Sarl Syntax use stdlib trapz Y trapz X Y trapz X Y dim wn ou tl Description trapz Y calculates an approximation of the integral of a function given by the samples in Y with unit intervals The trapezoidal approxi mation is used If Y is an array integration is performed along the first non singleton dimension trapz X Y specifies the location of the samples A third argument may be used to specify along which dimension the integration is per formed Example use stdlib
169. d the hour is between 1 and 12 other wise between 0 and 23 Examples use date datestr clock 18 Apr 2005 16 21 55 datestr clock ddd mm dd yyyy HH MM PM Mon 04 18 2005 04 23 PM See also julian2cal datevec String to date and time conversion Syntax use date datetime datevec str Description datevec str converts the string str representing the date and or the time to a row vector of 6 elements for the year month day hour minute and second The following formats are recognized 500 LyME User Manual 1999 2008 Calerga Sarl Example Value 20050418T162603 ISO 8601 date and time 2005 04 18 year month and day 2005 Apr 18 year month and day 18 Apr 2005 day month and year 04 18 2005 month day and year 04 18 00 month day and year 18 04 2005 day month and year 18 04 05 day month and year 16 26 03 hour minute and second 16 26 hour and minute PM afternoon Unrecognized characters are ignored If the year is given as two digits it is assumed to be between 1951 and 2050 Examples use date datevec Date and time 20050418T162603 2005 4 18 16 26 3 datevec 03 57 PM 0 0 0 15 57 0 datevec 1 Aug 1291 1291 8 1 0 0 0 datevec At 16 30 on 11 04 07 2007 11 4 16 30 0 See also weekday Week day of a given date Syntax use date num str weekday year month day num str weekday datetime num str weekday jd Description weekday finds th
170. d M returns the vector of sin gular values s diag S The singular values of M can also be computed with s sqrt eig M M but svd is faster and more robust Examples U S V svd 1 2 3 4 U ry 0 4046 0 9145 0 9145 0 4046 S 5 465 0 0 0 366 V 0 576 0 8174 0 8174 0 576 U S V 12 34 232 LyME User Manual 1999 2008 Calerga Sarl svd 1 2 1 2 3 1623 3 4697e 19 See also trace Trace of a matrix Syntax tr trace M Description trace M returns the trace of the matrix M i e the sum of its diagonal elements Example trace 1 2 3 4 5 See also var Variance of a set of values Syntax s2 var A s2 var A p s2 var A p dim LME Reference arrays 233 Description var A gives the variance of the columns of array A or of the row vector A The variance is normalized with the number of observations minus 1 or by the number of observations if a second argument is true The dimension along which var proceeds may be specified with a third argument See also 3 15 Array Functions cat Array concatenation Syntax cat dim Al A2 Description cat dim A1 A2 concatenates arrays Al A2 etc along dimen sion dim Other dimensions must match cat is a generalization of the comma and the semicolon inside brackets Examples cat 2 1 2 3 4 5 6 7 8 12 5 6 3 4 7 8 cat 3 1 2 3 4 5 6 7 8 2x2x2 array See also operator T
171. d from an array whose size is specified by size by the single index ind size must be either a scalar for square matrices or a vector of two elements or more for arrays ind can be an array the result is calculated separately for each element and has the same size Example M 3 6 8 9 M 3 8 i j ind2sub size M 3 j LME Reference arrays 241 See also interpl 1D interpolation Syntax yi interpl x y xi yi interpl x y xi xi method yi interpl y xi xi yi T xi xi method yi interpl method extraval Description interp1 x y xi interpolates data along one dimension Input data are defined by vector y where element y i corresponds to coordi nates x i Interpolation is performed at points defined in vector x1 the result is a vector of the same site as xi If y is an array interpolation is performed along dimension 1 i e along its columns and size y 1 must be equal to Llength x Then if xi is a vector interpolation is performed at the same points for each remaining dimensions of y and the result is an array of size length xi size y 2 end if xi is an array all sizes must match y except for the first one The default interpolation method is linear An additional input argu ment can be provided to specify it with a string only the first character is considered Argument Meaning 0 or nearest nearest value LA lt lower coordinate gt hig
172. dentical zeros and poles are canceled out minreal a tol uses tolerance tol to decide whether to discard a state or a pair of pole zero Iti minus System difference Syntax use lti a b minus a b Description a b computes the system whose inputs are fed to both a and b and whose outputs are the difference between outputs of a and b Ifa and b are transfer functions or matrices of transfer functions this is equivalent to a difference of matrices See also lti parallel lti uminus Iti mldivide System left division 478 LyME User Manual 1999 2008 Calerga Sarl Syntax use lti c a b C mldivide a b Description a b is equivalent to inv a b See also lti mrdivide lti times lti inv Iti mrdivide System right division Syntax use lti C a b C mrdivide a b Description a b is equivalent to axinv b See also t1i mldivide ilt1i times Lt1 1nv Iti mtimes System product Syntax use lti c axb c mtimes a b Libraries lti 479 Description axb connects the outputs of lti object b to the inputs of lti object a If a and b are transfer functions or matrices of transfer functions this is equivalent to a product of matrices See also lti series Iti norm H2 norm Syntax use lti h2 norm a Description norm a gives the H2 norm of the system a See also ss obsv Observability matrix Syntax use lti 0 obsv a Description
173. displays the ratio result of an expression which does not end with a semicolon See also disp ratio double Convert a ratio object to a floating point number Syntax use ratio x double r Description double r converts ratio r to a floating point number of class double Example use ratio r ratio 2 3 double r 0 6666 See also ratio ratio Libraries bitfield 449 4 5 bitfield Library bitfield implements the constructor and methods of class bitfield for bit fields binary numbers Basic arithmetic operators and functions are overloaded to support expressions with the same syntax as for numbers and matrices Contrary to integer numbers bitfield objects have a length between 1 and 32 and are displayed in binary The following statement makes available functions defined in bitfield use bitfield bitfield beginning First bit position in a bitfield Syntax use bitfield a beginning Description In the index expression of a bitfield beginning is the position of the least significant bit i e 0 See also bitfield bitfield Bitfield object constructor Syntax use bitfield a bitfield a bitfield n a bitfield n wordlength 450 LyME User Manual 1999 2008 Calerga Sarl Description bitfield n wordlength creates a bitfield object initialized with the wordlength least significant bits of the nonnegative integer number n The default value of wordlength is 32 if
174. e a 123 See also struct fl1eldnames rmfield Deletion of a field in a structure Syntax strctout rmfield strctin name Description strctout rmfield strctin name makes a structure strctout with the same fields as strctin except for field named name which is re moved If field name does not exist strctout is the same as strctin LME Reference structures 317 Example x rmfield struct a 1 3 b abc a fieldnames x b See also getfield forderfields setfield Assignment to a field in a structure Syntax strctout setfield strctin name value Description strctout setfield strctin name value makes a structure strctout with the same fields as strctin except that field named name is added if it does not exist yet and is set to value s setfield s f v has the same effect as s f v s setfield s str v has the same effect as s str v See also struct Creation of a structure Syntax strct struct fieldnamel valuel fieldname2 value2 Description struct builds a new structure Input arguments are used by pairs to create the fields for each pair the first argument is the field name provided as a string and the second one is the field value 318 LyME User Manual 1999 2008 Calerga Sarl Example x struct a 1 b 2 5 X a 1 x b 2345 See also structarray isstruct isfield rmfield f1eldnames operator
175. e in read only mode Both arguments are strings vfsopen volume path mode opens a file in read only mode if mode is r or in read write mode if mode is w 368 LyME User Manual 1999 2008 Calerga Sarl Example fd vfsopen Data Measures data txt w for i 1 size data 1 fprintf g t data i fprintf n end fclose fd See also vfsrename Rename a file or a directory Syntax vfsrename volume path newname Description vfsrename volume path newname changes the name of the file or directory whose absolute path is path on volume volume to newname All arguments are strings Example vfsrename Pictures DCIM 0003 jpg jean jpg See also 3 29 Time Functions clock Current date and time Syntax t clock LME Reference time functions 369 Description clock returns a 1x6 row vector containing the year four digits the month the day the hour the minute and the second of the current date and time All numbers are integers except for the seconds which are fractional The absolute precision is plus or minus one second with respect to the computer s clock the relative precision is plus or minus 1 microsecond on a Macintosh and plus or minus 1 millisecond on Windows Example clock 1999 3 11 15 37 34 9167 See also tic Start stopwatch Syntax tic Description tic resets the stopwatch Typically tic is
176. e real complex or integer or a character or logical array To keep the integer type of logical and character arrays the unitary operator should be used instead Examples double uint8 3 3 double AB 65 66 islogical double 1 gt 2 false LME Reference mathematical functions 151 See also and related functions Single cast operator sets tr char logical ellipam Jacobi elliptic amplitude Syntax phi ellipam u m phi ellipam u m tol Description ellipam u m gives the Jacobi elliptic amplitude phi Parameter m must be in 0 1 The Jacobi elliptic amplitude is the inverse of the Jacobi integral of the first kind such that u F g m ellipam u m tol uses tolerance tol the default tolerance is eps Example phi ellipam 2 7 0 6 2 0713 u ellipf phi 0 6 2 7 See also ellipf lellipj ellipe Jacobi elliptic integral of the second kind Syntax u ellipe phi m 152 LyME User Manual 1999 2008 Calerga Sarl Description ellipe phi m gives the Jacobi elliptic integral of the second kind defined as o E g m A V1 msin tdt 0 Complete elliptic integrals of first and second kinds with phi pi 2 can be obtained with ellipke See also ellipf jellipke ellipf Jacobi elliptic integral of the first kind Syntax u ellipf phi m Description ellipf phi m gives the Jacobi elliptic integral of the first kind de fined as F g m i
177. e M2 size M1 M1 M2 M1 M1 M2 M1 M2 M2 and the norm of M2 is minimum To pseudo inverse is based on the singular value decomposition where only the singular values larger than some small threshold are considered This threshold can be specified with an optional second argument If M1 is a full rank matrix with more rows than columns pinv returns the least square solution pinv M1 xy M1 M1 M1 xy of the over determined system M1 x y Examples 0 2 0 4 1 2 x M2 1 2 1 2 M2 x 1 2 M2 0 2 0 4 See also poly Characteristic polynomial of a square matrix or polynomial coefficients based on its roots LME Reference linear algebra 221 Syntax pol poly M pol poly r Description With a matrix argument poly M returns the characteristic polyno mial det x eye size M M of the square matrix M The roots of the characteristic polynomial are the eigenvalues of M With a vector argument poly r returns the polynomial whose roots are the elements of the vector r The first coefficient of the polynomial is 1 If the complex roots form conjugate pairs the result is real Examples poly 1 2 3 4 1 5 2 roots poly 1 2 3 4 5 3723 0 3723 eig 1 2 3 4 0 3723 5 3723 poly 1 3 1 6 11 6 See also polyder Derivative of a polynomial or a polynomial product or ratio Syntax Al polyder A C1 polyder A B N1 D1 polyder N D Description polyder
178. e an alternative often easier way of creat ing inline functions The result is the same Since inline is a normal function it must be used in contexts where fixed parameters cannot be created as separate variables Examples A simple expression evaluated at x 1 and x 2 fun inline cos x exp x y feval fun 2 LME Reference miscellaneous functions 89 y 5 6319e 2 feval fun 5 1 9113e 3 lt l A function of x and y fun inline exp x 2 y 2 x y A function with two output arguments the string is broken in three lines to have a nice program layout a mean v b prod v 1 length v 71 am gm feval fun 1 10 am 5 5 fun inline function a b f v gm 4 5287 Simple expression with fixed parameter a fun inline cos a x x struct a 2 feval fun 3 0 9602 An equivalent function where the source code of a complete function is provided fun inline function y f a x y cos a x 2 feval fun 3 0 9602 A function with two fixed parameters a and b whose values are pro vided in a list inline function y f p x a b deal p y a x b 2 3 An inline function with a variable number of output arguments n inline eig exp x true feval fun magic 3 fu e e 2867 4882 3173 2074 2903 9354 V D feval fun magic 3 V 0 0642 0 9579 0 8916 90 LyME User Man
179. e coefficients of the polynomials highest power at left List of n roots n by 1 matrix List of n roots for m polynomials of same degree n matrix n by m Single index One by one matrix List of indices Any kind of matrix the real part of each element taken row by row is used Sets Numerical array or list or cell array of strings see below Boolean value One by one logical array 0 means false and any other value including nan means true comparison and logical operators and functions return logical values In programs and expressions constant boolean values are entered as false and true Scalar boolean values are displayed as false or true in arrays respectively as F or T 34 LyME User Manual 1999 2008 Calerga Sarl String Usually 1 by n char array but any shape of char arrays are also accepted by most functions Unless a conversion function is used explicitly numbers are repre sented by double or complex values Most mathematical functions ac cept as input any type of numerical value and convert them to double they return a real or complex value according to their mathematical definition Basic element wise arithmetic and comparison operators accept di rectly integer types element wise means the operators and the functions mod and rem as well as operators with a scalar multiplicand or divisor If their arguments do not have the same type they are converted to the size of the largest ar
180. e for all outputs If the state space model has multiple inputs a fifth input argument is required and spec ifies which one to consider For a sampled time model exactly the same function can be used The derivative is replaced by a forward shift and the variable s of the Laplace transform is replaced by the variable z of the z transform But as long as coefficients are concerned the conversion is the same The degree of the denominator is equal to the number of states i e the size of A The degree of the numerator is equal to the number of states if D is not null and one less if D is null Example num den ss2tf 1 1 1 0 num 1 den 1 See also 340 LyME User Manual 1999 2008 Calerga Sarl tf2ss Conversion from transfer function to state space Syntax A B C D tf2ss num den Description tf2ss num den returns the state space representation of the trans fer function num den which is given as two polynomials The transfer function must be causal i e num must not have more columns than den Systems with several outputs are specified by a num having one row per output the denominator den must be the same for all the outputs tf2ss applies to continuous time systems Laplace transform as well as to discrete time systems z transform or delta transform Example A B C D tf2ss 2 5 2 3 8 A 1 5 4 10 a Slriori N U See also 3 25 Input Output Functions bwrite Store da
181. e magnitude of the Bode diagram of system a Libraries lti 487 See also ti nichols lt1 nyquist Iti bodephase Phase of the Bode plot Syntax use lti bodephase a bodephase a Description bodephase a plots the magnitude of the Bode diagram of system a See also ti bodemag lti nichols Tti nyquist Iti impulse Impulse response Syntax use lti impulse a impulse a Description impulse a plots the impulse response of system a See also Lti step lti tanita l Iti initial Time response with initial conditions 488 LyME User Manual 1999 2008 Calerga Sarl Syntax use lti initial a x0 initial a x0 Description initial a x0 plots the time response of state space system a with initial state xO and null input See also lti impulse lt1 step Iti lsim Time response Syntax use lti lsim a u t lsim a u t Description lsim a u t plots the time response of system a For continuous time systems The input is piece wise linear it is defined by points in real vectors t and u which must have the same length Input before t 1 and after t end is 0 For discrete time systems u is sampled at the rate given by the system and t is ignored or can be omitted See also Lti step Lti initial Iti nichols Nichols plot Syntax use lti nichols a nichols a Libraries lti 489
182. e same minimum value only the first one is obtained The argument type can be double single or integer of any size min M operates on the columns of the matrix M and returns a row vector min M dim operates along dimension dim 1 for columns 2 for rows min M1 M2 returns a matrix whose elements are the minimum be tween the corresponding elements of the matrices M1 and M2 M1 and LME Reference linear algebra 217 M2 must have the same size or be a scalar which can be compared against any matrix Examples mx ix min 1 3 2 5 8 7 mx 1 ix 1 min 1 3 5 nan 2 1 5 min 1 3 5 nan 2 12 22 See also max moment Central moment of a set of values Syntax m moment A order m moment A order dim Description moment A order gives the central moment moment about the mean of the specified order of the columns of array A or of the row vector A The dimension along which moment proceeds may be specified with a third argument Example moment randn 1 10000 3 3 011 See also 218 LyME User Manual 1999 2008 Calerga Sarl norm Norm of a vector or matrix Syntax x norm v x norm v kind x norm M x norm M kind Description With one argument norm calculates the 2 norm of a vector or the induced 2 norm of a matrix The optional second argument specifies the kind of norm Kind Vector Matrix none or2_ sqrt sum abs v 2 largest singular value induced 2
183. e used to re trieve the element corresponding to the i th row and the j th column of an array whose size is specified by size size must be either a scalar for square matrices or a vector of two elements or more for other arrays If i and j are arrays they must have the same size the result is calculated separately for each element and has the same size Example M 3 6 8 9 M 2 1 8 sub2ind size M 2 1 7 M 3 8 See also tril Extraction of the lower triangular part of a matrix Syntax L L tril M tril M k Description tril M extracts the lower triangular part of a matrix the result is a matrix of the same size where all the elements above the main di agonal are set to zero A second argument can be used to specify another diagonal O is the main diagonal positive values are above and negative values below Examples M magic 3 M 816 264 LyME User Manual 1999 2008 Calerga Sarl ct ct ap i gt AWOH BW Or Bw en Se ey N OO gt NN NN O See also triu triu Extraction of the upper triangular part of a matrix Description tril M extracts the upper triangular part of a matrix the result is a matrix of the same size where all the elements below the main di agonal are set to zero A second argument can be used to specify another diagonal 0 is the main diagonal positive values are above and negative values below Examples QOoorooor AWO il il magi
184. e week day of the date given as input The date can be given with three input arguments for the year the month and the Libraries constants 501 day or with one input argument for the date or date and time vector or julian date The first output argument is the number of the day from 1 for Sunday to 7 for Saturday and the second output argument is its name as a string of 3 characters such as Mon for Monday Example Day of week of today use date num str weekday clock num 2 str Mon See also cal2julian 4 11 constants constants is a library which defines physical constants in SI units me ter kilogram second ampere The following statement makes available constants defined in constants use constants The following constants are defined 502 Name avogadro_number boltzmann_constant earth_mass earth_radius electron_charge electron_mass faraday_constant gravitational_constant gravity_acceleration hubble_constant ice_point induction_constant molar_gaz_constant molar_volume muon_mass neutron_mass plank_constant plank_constant_reduced plank_mass proton_mass solar_radius speed_of_light speed_of_sound stefan_boltzmann_constant vacuum_permittivity Value 6 0221367e23 1 380658e 23 5 97370e24 6 378140e6 1 60217733e 19 9 1093897e 31 9 6485309e4 6 672659e 11 9 80655 3 2e 18 273 15 1 256e 6 8 314510 22 41410e 3 1 8835327e 28 1 6749286e 27 6 6260755e 34 1 054572
185. eakpoint and clear it dbstatus stdlib linspace 0 dbclear 74 LyME User Manual 1999 2008 Calerga Sarl See also dequi dbstop Set a breakpoint Syntax dbstop fun dbstop fun line dbstop fun line Description dbstop funsets a breakpoint at the beginning of function fun dbstop fun line or dbstop fun line sets a breakpoint in function fun at line Line When LME executes a line where a breakpoint has been set it sus pends execution and returns to the command line interface The user can inspect or change variables executes expressions or other func tions continue execution with dbstep or dbcont or abort execution with dbquit Example use stdlib dbstop linspace dbstatus stdlib linspace 0 dbclear lLinspace See also dbtype Display source code with line numbers breakpoints and current exe cution point Syntax dbtype fun dbtype LME Reference debugging commands 75 Description dbtype fun displays the source code of function fun with line num bers breakpoints and the position where execution is suspended if itis in fun Without argument dbtype displays the function which is suspended dbtype can be used at any time to check the source code of any function known to LME Example use stdlib dbstop lLinspace Linspace 1 2 5 lt linspace 8 gt if nargin lt 3 dbstep lt lLinspace 11 gt r xl x2 x1 x O n 1 n 1 dbtype 6 function r linspace xl x2
186. eamingopen filename mode creator sets the creator to the four character string creator The default is LyME filestreamingopen card where card is an integer number specifies the card where the file is stored The default is O internal memory See also 364 LyME User Manual 1999 2008 Calerga Sarl 3 28 Palm VFS Functions The Virtual File System VFS enables the operating system to support different kinds of file systems It is available in Palm OS 4 and later For flash memory cards the VFAT format is used Multiple formats can coexist on the same handheld VFS files and directories are identified with two strings the volume name and the full path This differs from other file systems where the path contains enough information to identify the volume LyME pro vides two functions for opening a file vfsopen with separate volume name and path and fopen compatible with other LME applications like Sysquake Functions directly related to VFS are described below Input output and control are done with the following generic functions Function Description fclose close the file feof check end of file status fgetl read a line fgets read a line fprintf write formatted data fread read data fscanf read formatted data fseek change the current I O position ftell get the current I O position fwrite write data redirect redirect output fopen Open a VFS file Syntax fd fopen path fd fopen path mode
187. ect 470 d2c 471 dcgain end eval fr 472 feedback 474 impulse inv 474 isct 4 5 isdt 475 isempty isproper issiso 476 lsim 488 minreal 477 minus 477 mldivide 477 LyME User Manual 1999 2008 Calerga S rl mrdivide 478 mtimes nichols 488 norm 479 nyquist parallel plus repmat 481 series 481 size 482 ssdata 482 step 489 ae subsref tfdata 484 uminus 485 upLus 485 class polynom diff 440 disp double feval 441 inline 441 int 440 Oe subst class ratfun den 444 diff 444 disp feval inline 445 num 443 rat fun 442 class ratio char 447 disp double ratio 446 class ss augstate 469 to a initial 487 obsv 479 ss 466 class tf Index c D oO D 00 fn cle clea clf cloc clos colon compa compl cond 1 conj 1 conti conto conv conv2 193 corrcoe cos cosh cot coth cov cros csc l csch 14 ctranspose cumprod cumsum 196 cumt rapz 414 d2cm dare 196 datestr 498 datevec 499 dbclear 69 dbcont 70 dbdeldb 357 dbdelrec dbdir 3 dbhalt dbinfo dbnewdb 359 dbnewrec 36 dbnumrec 360 dbopenrec 361 dbquit dbset 362 o afu Jw cs OD FO BS Oo 3 CS AO X lt ps Fes fe KS Bs k LC o NIHH ANI o ola oo FI 01 Ol 00 P UT Aw ul fo 13 H N H lji gt gt oo amp oO
188. ect constructor Syntax use classes a ratfun a ratfun coefnum a ratfun coefnum coefden Description ratfun coefnum coefden creates a ratfun object initialized with the coefficients in vectors coefnum and coefden given in descending pow ers of the variable Without argument ratfun returns a ratfun object initialized to 0 If omitted coefden defaults to 1 The following operators and functions may be used with ratfun ar guments with results analog to the corresponding functions of LME Libraries classes 443 inv mtimes minus plus mldivide uminus mpower uplus mrdivide Example use classes r ratfun 3 0 1 4 2 2 5 0 1 r 3x 4 x 2 4x 2 2x 3 5x 2 1 See also polynom polynom ratfun disp Display a ratfun object Syntax use classes disp a Description disp a displays rational function a It is also executed implicitly when LME displays the ratfun result of an expression which does not end with a semicolon See also ratfun ratfun disp ratfun num Get the numerator of a ratfun as a vector of coefficients Syntax use classes coef num a 444 LyME User Manual 1999 2008 Calerga Sarl Description num a gets the numerator of a as a row vector of descending power coefficients See also ratfun ratfun ratfun den Get the denominator of a ratfun as a vector of coefficients Syntax use classes coef den a Descriptio
189. ect fd fdTarget redirect fd fdTarget copy redirect fd R redirect fd redirect R redirect Description redirect fd fdTarget redirects output from file descriptor fd to fdTarget fd must be 1 for standard output or 2 for standard error If fdTarget fd the normal behavior is restored redirect fd fdTarget copy copies output to both fd and fdTarget if copy is true instead of redirecting it only to fdTarget If copy is false the result is the same as with two input arguments With zero or one input argument and without output argument redirect displays the current redirection for the specified file descrip tor 1 or 2 or for both of them Note that the redirection itself may alter where the result is displayed With an output argument redirect returns a 1 by 2 row vector if the file descriptor is specified or a 2 by 2 matrix otherwise The first column contains the target file descriptor and the second column 1 for copy mode and 0 for pure redirection mode LME Reference input output 351 Examples Create a new file diary txt and copy to it both standard output and error fd fopen diary txt redirect 1 fd true redirect 2 fd true w Stop copying standard output and error and close file redirect 1 1 redirect 2 2 fclose fd Redirect standard error to standard output and get the redirection state redirect 2 1 redirect stdout stderr redirect 2 stderr fd 2
190. element is the index of the system input where the connection ends other elements are indices to system outputs which are summed The sign of the indices to outputs gives the sign of the unit weight in the sum Zeros are ignored Arguments in and out specify which input and output to keep See also lti feedback Iti d2c Conversion from discrete time to continuous time Syntax use lti b d2c a b d2c a method Description d2c a converts the discrete time system a to a continuous time sys tem d2c a method uses the specified conversion method method is one of the methods supported by d2cm See also Uti c2d Iti end Last index Syntax use lti var end 472 LyME User Manual 1999 2008 Calerga Sarl Description In an expression used as an index between parenthesis end gives the last valid value for that index It is size var 1 or size var 2 Example Time response when the last input is a step use lti P ss 1 2 3 4 1 0 0 1 3 5 P1 P end continuous time LTI state space system A 1 2 3 4 B step P1 See also Uti beginning lti subsasgn lti subsref Iti evalfr Frequency value Syntax use lti y evalfr a x Description evalfr a x evaluates system a at complex value or values x If x is a vector of values results are stacked along the third dimension Libraries lti 473 Example use lti sys tf 1 1 2 3 tf 2
191. ematic notation and a table of contents and an index have been added The same method has been used to create the material for the help command Thanks to the make utility the whole process is completely automatic This system has proved to be very flexible to maintain three useful formats in parallel two for on line help and one for high quality printing World Wide Web http www calerga com E mail sysquake calerga com Mail alerga Sar Av de la Chabli re 35 1004 Lausanne Switzerland Typesetting 2008 8 2 Contents 1 Using LyME 5 Aaah We ented Sata Gn ee ee ee ee A 5 1 2 Using LYME see ke eae ee he cod bao ee ee ee 5 1 3 User inpUt e ba aos een tee eae aoe eee ee ee as 12 1 4 Dataexchange 2 0 000002 eee eee 13 L5 License 2 eee ce eee ee ew eee em i omidi 13 Pie Eisai i al wot 14 L Math iby oe wis eae ee a Es oe ee ei BR Os 14 2_LME Tutorial 15 2 1 Simple operations 00000008 15 2 2 Complex Numbers 0002 0000 eae 16 2 3 Vectors and Matrices 00 005 18 2 4 Polynomials 000000 eee eee 21 2 9 SINGS ss cies hye ah ee ew oe Ge ee ee ee o Aed 22 2 0 VarlabDleS s sei koe ew sa we acd S EES Bas 22 2 7 Loops and Conditional Execution 23 2 8 _ FUNCHIONS ssi tera ee ee be ee SG ee ee N 23 2 9 Local and Global Variables 26 29 3 1 Programformat
192. encoding which maps each integer of s bits to another integer of s bits such that two consecutive codes i e graycode n and graycode n 1 for any n have only one bit which differs Example graycode 0 7 01326754 See also igraycode igraycode Conversion from Gray code Syntax n igraycode g Description igraycode n converts the Gray code g to the corresponding integer It is the inverse of graycode The argument n can be an integer num ber of class double converted to an unsigned integer or any integer type If it is an array conversion is performed on each element The result has the same type and size as the input Example igraycode graycode Q 7 01234567 See also islogical Test for a boolean object LME Reference logical functions 331 Syntax b islogical obj Description islogical obj is true if obj is a logical value and false otherwise The result is always a scalar even if obj is an array Logical values are obtained with comparison operators logical operators test functions and the function Logical Examples islogical eye 10 false islogical eye 10 true See also logical Transform a number into a boolean Syntax B logical A Description logical x converts array or number A to logical boolean type All nonzero elements of A are converted to true and zero elements to false Logical values are stored as 0 for false or 1 for true in
193. ency of w0 relatively to half the sampling frequency cheby1 n wl wh stop where the second input argument is a vector of two numbers gives a 2nth order digital bandstop filter with stopband between wl and wh relatively to half the sampling frequency With an additional input argument which is the string s cheby1 gives an analog Chebyshev type 1 filter Frequencies are given in rad s Libraries filter 461 See also cheby2 Chebyshev type 2 filter Syntax use filter Z k cheby2 n w0 num den cheby2 n w0 cheby2 n wl wh cheby2 n w0 high cheby2 n wl wh stop cheby2 s Description cheby2 calculates a Chebyshev type 2 filter The result is given as zeros poles and gain if there are three output arguments or as nu merator and denominator coefficient vectors if there are two output arguments cheby2 n w0 where w0 is a scalar gives a nth order digital low pass filter with a cutoff frequency of w0 relatively to half the sampling frequency cheby2 n wl wh where the second input argument is a vector of two numbers gives a 2nth order digital bandpass filter with pass band between wl and wh relatively to half the sampling frequency cheby2 n w0 high gives a nth order digital highpass filter with a cutoff frequency of w0 relatively to half the sampling frequency cheby2 n wl wh stop where the second in
194. ent or a programming construct Statements are separated by commas semicolons or end of lines The end of line has the same meaning as a comma unless the line ends with a semicolon When simple expressions and assignments are followed by a comma or an end of line the result is displayed to the standard output when they are followed by a semicolon no output is produced What follows programming constructs does not matter When typed at the command line the result of simple expressions is assigned to the variable ans this makes easy reusing intermediate results in successive expressions Continuation characters A statement can span over several lines provided all the lines but the last one end with three dots For example 1 2 is equivalent to 1 2 After the three dots the remaining of the line as well as empty lines and lines which contain only spaces are ig nored 30 LyME User Manual 1999 2008 Calerga Sarl Inside parenthesis or braces line breaks are permitted even if they are not escaped by three dots Inside brackets line breaks are matrix row separators like semicolons Comments Unless when it is part of a string enclosed between single ticks a single percent character or two slash characters mark the beginning of a comment which continues until the end of the line and is ignored by LME Comments must follow continuation characters if any a 2 comment at the end of a line x 5 another co
195. ent can be used to specify the access mode Mode Description npe read w write after discarding the previous contents a append to the end of the previous contents The functions which can be used in write or append mode include fprintf fwrite and dumpvar Example Reading of the first line of the first note for the Memo Pad application fd dbopenrec MemoDB 0 line fgets fd fclose fd See also dbnewrec 362 LyME User Manual 1999 2008 Calerga Sarl dbset Set options for dbnewdb Syntax options dbset options dbset namel valuel options dbset options0 namel valuel Description dbset namel valuel creates the option argument used by dbnewdb Options are specified with name value pairs where the name is a string which must match exactly the names in the table below Case is significant Options which are not specified have a default value The result is a structure whose fields correspond to each option Without any input argument dbset creates a structure with all the default options Note that dbnewdb also interprets the lack of an option argument or the empty array as a request to use the default values When its first input argument is a structure dbset adds or changes fields which correspond to the name value pairs which follow Here is the list of permissible options Name Default Meaning Backup true should be backed up Bundle false bundled with its application C
196. er Manual 1999 2008 Calerga Sarl Description atan2 y x gives the direction of a point given by its Cartesian coor dinates x and y Imaginary component of complex numbers is ignored atan2 y x is equivalent to atan y x if x gt 0 Examples atan2 1 1 0 7854 atan2 1 1 2 3562 atan2 0 0 0 See also atanh Inverse hyperbolic tangent Syntax y atanh x Description atan x gives the inverse hyperbolic tangent of x which is complex if x is complex or if abs x gt 1 Examples atanh 0 5 0 5493 atanh 2 0 5493 1 5708j See also beta Beta function LME Reference mathematical functions 143 Syntax y beta z w Description beta z w gives the beta function of z and w Arguments and result are real imaginary part is discarded The beta function is defined as 1 B z w f 1 0 de 0 Example beta 1 2 0 5 See also betainc Incomplete beta function Syntax y betainc x z w Description betainc x z w gives the incomplete beta function of x z and w Arguments and result are real imaginary part is discarded x must be between 0 and 1 The incomplete beta function is defined as 1 x I z w fo f tdt ee al a Example betainc 0 2 1 2 0 36 See also gammainc 144 LyME User Manual 1999 2008 Calerga Sarl betaln Logarithm of beta function Syntax y betaln z w Description betaln z w gives the logarithm of the beta funct
197. erga Sarl Syntax s swrite data s swrite data precision Description swrite fd data stores the contents of the matrix data in a string The third parameter is the precision whose meaning is the same as for fread Its default value is uint8 Examples swrite 65 68 ABCD double swrite 1 2 int16 1020 double swrite 1 2 int16 b 0102 See also 3 26 Palm Database Functions On Palm OS databases are the most common way to store data They replace files on computers Databases are identified by a name and have a four character creator which links them to an application and a four character type They contain multiple records identified by an index the first record has index 0 Functions specific to databases are described in this section Input output and control are done with the following generic functions Function Description fclose close the record feof check end of record status fgetl read a line fgets read a line fprintf write formatted data fread read data fscanf read formatted data fseek change the current I O position ftell get the current I O position fwrite write data redirect redirect output LME Reference Palm database 357 dbdeldb Delete a database Syntax dbdeldb dbName Description dbdelrec dbName deletes a database identified by its name dbName All its records are discarded See also dbnewdb dbdelrec dbdelrec Delete a database
198. erted to 32 bit unsigned integers each bit of the result is the binary exclusive OR of the corresponding bits of the inputs The inputs can be scalar arrays of the same size or a scalar and an array Examples bitxor 1 3 2 bitxor 1 6 1 032547 bitxor 7uint8 1234int16 1237int16 See also false Boolean constant false LME Reference logical functions 329 Syntax b false B false n B false nl n2 B false nl n2 Description The boolean constant false can be used to set the value of a variable It is equivalent to Logical 0 The constant 0 is equivalent in many cases indices to get or set the elements of an array are an important exception With input arguments false builds a logical array whose elements are false The size of the array is specified by one integer for a square matrix or several integers either as separate arguments or in a vec tor for an array of any size Examples false false islogical false true false 2 3 FFF FFF See also graycode Conversion to Gray code Syntax g graycode n Description graycode n converts the integer number n to Gray code The argu ment n can be an integer number of class double converted to an unsigned integer or any integer type If it is an array conversion is 330 LyME User Manual 1999 2008 Calerga Sarl performed on each element The result has the same type and size as the input Gray code is an
199. es Stable closed loop Nyquist inside unit circle gm pSsi wc wx margin 5 poly 1 1 1 gm 2 16 psi we 0 1 7321 wx Stable closed loop Nyquist crosses unit circle gm psi wc wx margin 4 poly 1 1 1 gm 0 25 2 psi 0 4737 we 0 1 7321 wx 1 2328 Unstable closed loop gm psi wc wx margin 10 poly 1 1 1 gm psi we wx Caveats Contrary to many functions margin cannot be used with several trans fer functions simultaneously because not all of them may correspond simultaneously to either stable or unstable closed loop systems See also ss2tf Conversion from state space to transfer function LME Reference dynamical systems 339 Syntax num den ss2tf A B C D den ss2tf A B C D num den ss2tf A B C D iu den ss2tf A B C D iu Description A continuous time linear time invariant system can be represented by the state space model Ax t Bu t Cx t Du t dx i I y t where x t is the state u t the input y t the output and ABCD four constant matrices which characterize the model If it is a single input single output system it can also be represented by its trans fer function num den num den ss2tf A B C D converts the model from state space to transfer function If the state space model has multiple outputs num is a matrix whose lines correspond to each output the denominator is the sam
200. es in a plane e g pixels to be filtered with the finite impulse response 2 d filter M2 With kind valid the result M has nl1 nl2 1 lines and nc1 nc2 1 columns or is the empty matrix if M1 represents data filtered by M2 the borders where the convolution sum is not totally included in M1 are removed Examples conv2 1 2 3 4 5 6 7 8 9 1 1 1 1 1 1 1 1 1 1 3 6 5 3 5 12 21 16 9 12 27 45 33 18 11 24 39 28 15 7 15 24 17 9 conv2 1 2 3 4 5 6 7 8 9 1 1 1 1 1 1 1 1 1 same 12 21 16 27 45 33 24 39 28 conv2 1 2 3 4 5 6 7 8 9 1 1 1 1 1 1 1 1 1 valid 45 See also conv 194 LyME User Manual 1999 2008 Calerga Sarl cov Covariance Syntax M M M cov data cov data 0 cov data 1 Description cov data returns the best unbiased estimate m by m covariance ma trix of the n by m matrix data for a normal distribution Each row of data is an observation where n quantities were measured The co variance matrix is real and symmetric even if data is complex The diagonal is the variance of each column of data cov data 0 is the same as cov data cov data 1 returns the m by m covariance matrix of the n by m matrix data which contains the whole population Example cov 1 2 2 4 3 5 11 5 1 5 2 3333 See also cross Cross product Syntax v3 v3 cross vl v2 cross vl v2 dim Description cross vl v2 gives the cross products of vectors v1 and v2 v1 and
201. es them They can also be declared in the workspace There exists only a single variable for each different name Declaring a global variable has the following result If a previous local variable with the same name exists it is deleted If the global variable does not exist it is created and initialized with the empty array Every access which follows the declaration in the same function or workspace uses the global variable Like global variables persistent variables are preserved between func tion calls but they cannot be shared between different functions They are declared with persistent They cannot be declared outside a function Different persistent functions can have the same name in different functions Examples Functions to reset and increment a counter function reset global counter counter 0 function value increment global counter counter counter 1 value counter Here is how the counter can be used reset i increment 50 LyME User Manual 1999 2008 Calerga Sarl i 1 j increment j 2 See also function matrixcol First index in a subscript expression Syntax A matrixcol function e C matrixcol obj i n Description In an expression used as a single subscript to access some elements of an array A expr matrixcol gives an array of the same size as A where each element is the column index For instance for a 2 by 3 matrix matrixcol gives
202. escription nansum v returns the sum of the elements of vector v NaN values are ignored nansum A returns a row vector whose elements are the sums of the corresponding columns of array A nansum A dim returns the sum of array A along dimension dim the result is a row vector if dim is 1 or a column vector if dim is 2 See also pdist Pairwise distance between observations Syntax use stat pdist M pdist M metric pdist M metric p a ou oul Description pdist calculates the distance between pairs of rows of the observation matrix M The result is a column vector which contains the distances between rows i and j with i lt j It can be resized to a square matrix with squareform By default the metric used to calculate the distance is the eu clidean distance but it can be specified with a second argument 434 LyME User Manual 1999 2008 Calerga Sarl euclid euclidean distance seuclid standardized euclidean distance mahal Mahalanobis distance cityblock sum of absolute values minkowski Minkowski metric with parameter p The standardized euclidean distance is the euclidean distance after each column of M has been divided by its standard deviation The Minkowski metric is based on the p norm of vector differences Examples use stat pdist 1 3 121 squareform pdist 1 3 012 101 210 squareform pdist 1 2 6 3 1 7 6 1 2 0 2 4495 6 4807 2 4495 0 5 831 6 4807 5 831 0 See
203. ever is larger If this cannot be achieved for instance if the system is stiff and requires an integration step smaller than MinStep integration is aborted Refine specifies how many points are added to the result for each integration step When it is larger than 1 additional points are interpolated which is much faster than reducing MaxStep The output function OutputFcn if defined is called after each step It is a function name in a string a function reference or an anonymous or inline function which can be defined as function stop outfun tn yn where tn is the time of the new samples yn their values and stop a logical value which is false to continue integrating or true to stop The number of new samples is given by the value of Refine when multiple values are provided tn is a row vector and yn is a matrix whose columns are the corresponding states The output function can be used for incremental plots for animations or for managing large amounts of output data without storing them in variables Events Events are additional time steps at controlled time to change instan taneously the states and to base the termination condition on the states Time instants where events occur are either given explicitly by EventTime or implicitly by Events There can be multiple streams of events which are checked independently and are identified by a positive integer for Events or a negative integer for EventTime For instance
204. f the result whatever the value of dim is Examples roots 1 0 1 1 1 roots 1 0 1 LME Reference linear algebra 1 1 roots 1 1 0 5 1 6 1 2 1 3 roots 1 0 1 2 See also schur Schur factorization Syntax U T schur A T schur A U T schur A c T schur A c Description 227 schur A computes the Schur factorization of square matrix A i e a unitary matrix U and a square matrix T the Schur matrix such that A U T U If Ais complex the Schur matrix is upper triangular and its diagonal contains the eigenvalues of A if A is real the Schur matrix is real upper triangular except that there may be 2 by 2 blocks on the main diagonal which correspond to the complex eigenvalues of A To force a complex Schur factorization with an upper triangular matrix T schur is given a second input argument c or complex Example U T schur 1 2 3 4 U 0 8246 0 5658 0 5658 0 8246 TE 0 3723 1 0 5 3723 eig 1 2 3 4 ans 0 3723 5 3723 228 LyME User Manual 1999 2008 Calerga Sarl T schur 1 0 0 0 1 2 0 3 1 T 1 0 0 0 1 2 0 3 1 T schur 1 0 0 0 1 2 0 3 1 c T 1 0 0 0 l 2 4495j 1 0 0 l 2 4495j See also skewness Skewness of a set of values Syntax skewness A skewness A dim S S Description skewness A gives the skewness of the columns of array A or of the row
205. fied its default value is l size y 2 bar x y w where w is scalar specifies the relative width of each bar with respect to the horizontal distance between the bars with values smaller than 1 bars are separated with a gap while with values larger than 1 bars overlap If wis a vector of two components w1 w2 w1 corresponds to the relative width of each bar in a group columns of y and w2 to the relative width of each group Default values used if wis missing or is the empty matrix is 0 8 for both w1 and w2 bar kind where kind is a string specifies the kind of bar plot The following values are recognized grouped Columns of y are grouped horizontally default stacked Columns of y are stacked vertically interval Same as grouped except that bars have min and max values With interval intervals are defined by two consecutive rows of y which must have an even number of rows The optional argument color is a string made of one or several color characters k black w white with a black frame First color is applied to first row of y second color to second row and so on if there are less colors than rows colors are recycled Examples bar 2 4 3 6 3 5 4 1 bar 1 4 magic 4 stacked bar 1 4 2 4 3 1 5 6 4 6 interval simple bar plot stacked bar plot interval plot X X See also barh Horizontal bar plot Syntax barh x barh y x LyME
206. fixed with 0x or 0X a binary number prefixed with Ob or OB or an octal number prefixed with 0 LME Reference input output 355 The decoded elements are accumulated in the output argument either as a column vector if the format string contains d 0 x i f e or g or a string if the format string contains only c s or literal values If a star is inserted after the percent character the value is decoded and discarded A width as one or more decimal characters can be inserted before s d x o i f e or g it limits the number of characters to be decoded In the input string spaces and tabulators are skipped before decoding s d x 0 i f e or g The format string is recycled as many times as necessary to de code the whole input string The decoding is interrupted if a mismatch occurs The optional second output argument is set to the number of ele ments decoded successfully may be different than the length of the first argument if decoding strings The optional third output argument is set to the number of characters which were consumed in the input string Examples sscanf f 2 3 f f 2 3 sscanf 12a34x778 d c 778 sscanf abc def abcdef sscanf abc def abc def sscanf 12 34 d d 34 sscanf 0275a0ff 2x 2 117 160 255 S c See also swrite Store data in a string 356 LyME User Manual 1999 2008 Cal
207. fun 0 5 2 0 odeset Stats true Number of function evaluations 289 Successful steps 42 Failed steps error too large 6 size yi 169 2 LME Reference non linear numerical functions 289 plot ti yi plot t y g State based events For simulating a ball bouncing on the ground an event is generated every time the ball hits the ground and its speed is changed instan taneously Let y 1 be the height of the ball above the ground and y 2 its speed SI units are used The state space model is y y 2 9 81 An event occurs when the ball hits the ground value y 1 isterminal false direction 1 When the event occurs a new state is computed yn 0 damping y 2 To integrate this the following functions are defined function yp ballfun t y damping yp y 2 9 81 function v te d ballevents t y damping v y 1 event when the height becomes negative te false do not terminate d 1 only for negative speeds function yn ballonevent t y i damping yn 0 damping y 2 Ball state is integrated during 5 s see Fig 3 3 with opt odeset Events ballevents OnEvent ballonevent t y ode45 ballfun 0 5 2 0 opt 1 plot t y Time events with discontinuous function If the function being integrated has discontinuities at known time in stants option EventTime can be used t
208. function endfunction must be the first element of a line Not all of the input and output arguments are necessarily used The caller fixes the number of input and output arguments which can be retrieved by the called function with nargin and nargout respec tively The unused input arguments from nargin 1 to the last one are undefined unless a default value is provided in the function defi nition with the definition function f x y 2 y is 2 when f is called with a single input argument The unused output arguments from nargout 1 to the last one do not have to be set but may be To redefine an operator which is especially useful for object meth ods see below use the equivalent function such as plus for operator The complete list is given in the section about operators To define a method which is executed when one of the input argu ments is an object of class class or a child in the classes hierarchy add class before the method function name To call it use only LME Reference programming constructs 59 the method name not the class name Examples Function with optional input and output arguments function Sum Prod calcSumAndProd x y if nargout return nothing to be computed end if nargin 0 make something to be computed x 0 end je if nargin lt 1 sum of elements of x Sum sum x else sum of x and y Sum X y end if nargout also compute the product if
209. functions logical LME Reference mathematical functions 185 sinh Hyperbolic sine Syntax y sinh x Description sinh x gives the hyperbolic sine of x which is complex if x is com plex Example sinh 2 3 6269 See also sqrt Square root Syntax r sqrt z Description sqrt z gives the square root of z which is complex if z is not real positive Examples sqrt 4 2 sqrt 1 4 9 3 4j 1 2 3j 2 1j See also 186 LyME User Manual 1999 2008 Calerga Sarl swapbytes Conversion between big endian and little endian representation Syntax Y swapbytes X Description swapbytes X swaps the bytes representing number X If Xis an array each number is swapped separately The imaginary part if any is discarded X can be of any numerical type swapbytes is its own inverse for real numbers Example swapbytes luint32 16777216uint32 See also typecast cast tan Tangent Syntax y tan x Description tan x gives the tangent of x which is complex if x is complex Example tan 2 2 185 See also tanh LME Reference mathematical functions 187 tanh Hyperbolic tangent Syntax y tanh x Description tanh x gives the hyperbolic tangent of x which is complex if x is complex Example tanh 2 0 964 See also typecast Type conversion with same binary representation Syntax Y typecast X type Description typecast X
210. g commands 69 If a continue statement is executed in the scope of the while loop statements following continue are ignored and a new loop is per formed if the while statement yields true Example e l i 28 while true forever eNew 1 1 i i if abs e eNew lt 0 001 break end e eNew i 2 xj 2 717 See also 3 9 Debugging Commands dbclear Remove a breakpoint Syntax dbclear fun dbclear fun line dbclear fun line dbclear Description dbclear fun removes all breakpoints in function fun dbclear fun Line or dbclear fun line removes the breakpoint in function fun at line number Line Without argument dbclear removes all breakpoints See also dbstop 70 LyME User Manual 1999 2008 Calerga Sarl dbcont Resume execution Syntax dbcont Description When execution has been suspended by a breakpoint or dbhalt it can be resumed from the command line interface with dbcont See also dbhalt Suspend execution Syntax dbhalt Description In a function dbhalt suspends normal execution as if a breakpoint had been reached Commands dbstep dbcont and dbquit can then be used from the command line to resume or abort execution See also abquit dbquit Abort suspended execution Syntax dbquit LME Reference debugging commands 71 Description When execution has been suspended by a breakpoint or dbhalt it can be aborted completely from the comm
211. g filter of degree n with a cutoff angular fre quency of 1 rad s Ripples in the passband have a peak to peak mag nitude of rp dB See also cheb2ap Chebyshev type 2 analog filter prototype Syntax use filter z p k cheb2ap n rs 460 LyME User Manual 1999 2008 Calerga Sarl Description cheb2ap n rs calculates the zeros the poles and the gain of a Chebyshev type 2 analog filter of degree n with a cutoff angular fre quency of 1 rad s Ripples in the stopband have a peak to peak mag nitude of rs dB See also chebyl1 Chebyshev type 1 filter Syntax use filter Z p k chebyl n w0 num den chebyl n w0 cheby1 n wl wh chebyl n w0 high chebyl n wl wh stop chebyl s Description chebyl calculates a Chebyshev type 1 filter The result is given as zeros poles and gain if there are three output arguments or as nu merator and denominator coefficient vectors if there are two output arguments cheby1 n w0 where w0 is a scalar gives a nth order digital low pass filter with a cutoff frequency of w0 relatively to half the sampling frequency cheby1 n wl wh where the second input argument is a vector of two numbers gives a 2nth order digital bandpass filter with pass band between wl and wh relatively to half the sampling frequency cheby1 n w0 high gives a nth order digital highpass filter with a cutoff frequ
212. ga Sarl Example v repeat v v sum v 1 until v end gt 100 V 1 2 4 8 16 32 64 128 See also return Early return from a function Syntax return Description return stops the execution of the current function and returns to the calling function The current value of the output arguments if any is returned return can be used in any control structure such as if or try or at the top level Example function dispFactTable n display the table of factorials from 1 to n if n return nothing to display end fwrite i i n for i 1 n fwrite 2d 3d n i prod 1 i end See also function LME Reference programming constructs 65 switch Conditional execution of statements depending on a number or a string Syntax switch expr case el sl case e2 e3 s23 case e4 e5 s45 otherwise so end switch string case strl sl case str2 s2 case str3 str4 s34 otherwise so end Description The expression of the switch statement is evaluated If it yields a number it is compared successively to the result of the expressions of the case statements until it matches one then the statements which follow the case are executed until the next case otherwise or end If the case expression yields a vector or a list a match occurs if the switch expression is equal to any of the elements of the case expres sion If no match is found
213. gument size in the fol lowing order double gt uint64 gt int64 gt uint32 gt int32 gt uint16 gt int16 gt uint8 gt int8 Functions which manipulate arrays such as reshape which changes their size or repmat which replicates them preserve their type To convert arrays to numerical char or logical arrays use func tions unary operator char or Logical respectively To convert the numerical types use functions double single or uint8 and similar functions Numbers Double and complex numbers are stored as floating point numbers whose finite accuracy depends on the number magnitude During computations round off errors can accumulate and lead to visible ar tifacts for example 2 sqrt 2 sqrt 2 which is mathematically 0 yields 4 4409e 16 Integers whose absolute value is smaller than 2 52 about 4 5e15 have an exact representation though Literal double numbers constant numbers given by their numerical value have an optional sign an integer part an optional fractional part following a dot and an optional exponent The exponent is the power of ten which multiplies the number it is made of the letter e or E followed by an optional sign and an integer number Numbers too large to be represented by the floating point format are changed to plus or minus infinity too small numbers are changed to 0 Here are some examples numbers on the same line are equivalent 123 123 123 123 00 12300e 2 2
214. hal setstr Conversion of an array to a string Syntax str setstr A Description setstr A converts the elements of array A to characters resulting in a string of the same size Characters are stored in unsigned 16 bit words 302 LyME User Manual 1999 2008 Calerga Sarl Example setstr 65 75 ABCDEFGHIJK See also shal Calculate SHA1 digest Syntax digest shal strb digest shal fd Description shal strb calculates the SHA1 digest of strb which represents bi nary data strb can be a string only the least significant byte of each character is considered or an array of bytes of class uint8 or int8 The result is a string of 40 hexadecimal digits It is believed to be hard to create the input to get a given digest or to create two inputs with the same digest shal fd calculates the SHA1 digest of the bytes read from file descriptor fd until the end of the file The file is left open SHA1 digest is an Internet standard described in RFC 3174 Example SHA1 digest of the three characters a b and c shal abc a9993e364706816aba3e25717850c26c9cd0d89d See also strcmp String comparison LME Reference strings 303 Syntax b strcmp sl1 s2 b strcmp sl s2 n Description strcmp s1 s2 is true if the strings s1 and s2 are equal i e same length and corresponding characters are equal strcmp s1 s2 n compares the strings up to the n th character Note
215. he compilation of an expression such as right parenthesis or a sub expression at the right of an operator for not followed by a single assignment for is followed by an expression or an assignment with multiple variables Bad variable name The left hand part of an assignment is not a valid variable name e g 2 3 String without right quote The left quote of a string was found but the right quote is missing Unknown escape character sequence Ina string the backslash character is not followed by a valid escape sequence Unexpected right parenthesis Right parenthesis which does not match a left parenthesis Unexpected right bracket Right bracket which does not match a left bracket Unrecognized or unexpected token An unexpected character was found during compilation Such as 1 end not in an index expression end was used outside of any index sub expression in an expression 44 LyME User Manual 1999 2008 Calerga Sarl beginning not in an index expression beginning was used outside of any index sub expression in an expression matrixcol not in an index expression matrixcol was used outside of any index sub expression in an expression matrixrow not in an index expression matrixrow was used outside of any index sub expression in an expression matrixrow or matrixcol used in the wrong index matrixrow was used in an index which was not the first one or matrixcol was used in an index which was not the only
216. her coordinate 1 or linear linear With vectors interp1 produces the same result as interpn vector orientations do not have to match though When the method is followed by a scalar number extraval that value is assigned to all values outside the range defined by x i e extrapolated values The default is NaN Examples One dimension interpolation 242 LyME User Manual 1999 2008 Calerga Sarl interpl 1 2 5 8 0 1 0 2 0 5 1 0 2 3 7 nan 0 2000 0 3000 0 8333 interpl 1 2 5 8 0 1 0 2 0 5 1 2 3 7 0 nan 0 2000 0 2000 1 0000 Interpolation of multiple values t 0 10 y sin t cos t tnew 0 0 4 8 ynew interpl t y tnew ynew 0 0000 1 0000 0 3366 0 8161 0 8564 0 2143 0 9894 0 1455 See also interpn Multidimensional interpolation Syntax Vi interpn xl xn V xil xin Vi interpn xl xn V xil xin method Vi interpn method extraval Description interpn x1 xn V xil xin interpolates data in a space of n dimensions Input data are defined by array V where element V i j Corresponds to coordinates x1 i x2 j etc Interpolation is performed for each coordinates defined by arrays xil xi2 etc which must all have the same size the result is an array of the same size Length of vectors x1 x2 must match the size of V along the corresponding dimension Vectors x1 x2 must be sorted
217. i deg of freedom v x chi2 deg of freedom v gamma shape a and A exponential exp mean F f deg of freedom v1 and v2 half normal half normal 9 Laplace laplace mean and scale lognormal logn mean 0 and st dev 1 normal norm mean 0 and st dev 1 Rayleigh rayl b Student s T t deg of freedom v uniform unif limits of the range 0 and 1 Weibull weib a and b See also 146 LyME User Manual 1999 2008 Calerga Sarl ceil Rounding towards infinity Syntax y ceil x Description ceil x gives the smallest integer larger than or equal to x If the argument is a complex number the real and imaginary parts are han dled separately Examples ceil 2 3 3 ceil 2 3 2 ceil 2 3 4 5j 3 4j See also complex Make a complex number Syntax z complex x y Description complex x y makes a complex number from its real part x and imag inary part y The imaginary part of its input arguments is ignored Examples complex 2 3 2 3j complex 1 5 2 14 2j 2 2j 3 2j 44 2j 5 2j LME Reference mathematical functions 147 See also conj Complex conjugate value Syntax w conj z Description conj z changes the sign of the imaginary part of the complex num ber z Example conj 1 2j 3 5j 4 0 1 2j 3 5j 4 0 See also cos Cosine Syntax y cos x Description cos x gives the cosine of x which is complex if x is complex Example cos 0 1 2j 1 2 0327 3 05
218. ich is the list containing the single subscript s When an assignment is made to the field of an object in a statement like A f B LME executes A subsasgn A s B where s is a structure with two fields s type which is and s subs which is the name of the field f in this case While the primary purpose of subsasgn is to permit the use of sub scripts with objects a built in implementation of subsasgn is provided for arrays when s type is for lists when s type is a list and for structures when s typeis Examples A 1 2 3 4 subsasgn A struct type subs 1 999 999 999 3 4 subsasgn A struct type subs 1 2 4 See also subsref Reference to a part of an array list or structure LME Reference programming constructs 53 Syntax B subsref A s Description When an object variable is subscripted in an expression like A s1 s2 LME evaluates subsref A s where subsref is a method of the class of variable A and s is a structure with two fields s type which is and s subs which is the list of subscripts s1 s2 If a subscript is the colon character which stands for all elements along the corresponding dimensions it is represented with the string in s subs When an object variable is subscripted in an expression like A s LME evaluates subsref A s where subsref is a method of the class of
219. ics and text output may be toggled with the T and G buttons at the top of the screen Graphics are usually scaled to fill the graphics area No axis is drawn because of the constrained screen size To check the scale tap anywhere in the graphics area and read the coordinates of the point below the pen Most graphical functions support an additional argument to specify the color Using LyME Edit Ld S aE vo 1 ae wed convene YA cumprodi dim cumuni dinm d cm num den Tz t d2crn A B0 D Ts t deconwiy w2 detis Aa a oe Figure 1 4 EDAEN T EREE Figure 1 5 mM eE plot sin 0 0 1 2 iy US Sa te ene al Figure 1 6 8 LyME User Manual 1999 2008 Calerga Sarl cee pote sin 0 0 1 2 pity x 29 1447 y 0 3201 k A ee ee ec eee Figure 1 7 Programs There are two kinds of programs in LyME scripts and functions Scripts are simply collections of statements variable assignments and ex pressions which are evaluated exactly as if they were written in the command field Functions collected in libraries have input and output arguments and local variables They cannot modify the workspace variables you define from the command field or from scripts Both scripts and functions are entered in an editor window and are saved in a persistant database Standard Edit menu commands are available to Cut Copy and Paste text in LyME or between LyME and other Palm applications such as Memo Pad
220. if f a Description diff a differentiates polynomial a Example use classes p polynom 3 0 1 4 2 q diff p 12x 3 2x 4 See also polynom polynom polynom int polynom int Polynom integral Syntax use classes int a Description int a integrates polynomial a Libraries classes 441 Example use classes p polynom 3 0 1 4 2 q int p 0 6x 5 0 3333x 3 2x 2 2x See also polynom polynom polynom diff polynom inline Conversion from polynom object to inline function Syntax use classes fun inline a Description inline a converts polynomial a to an inline function which can then be used with functions such as feval and ode45 Example use classes p polynom 3 0 1 4 2 fun inline p fun lt inline function gt dumpvar fun fun fun inline function y f x y polyval 3 0 1 4 2 x See also polynom polynom polynom feval polynom feval Evaluate a polynom object 442 LyME User Manual 1999 2008 Calerga Sarl Syntax use classes y feval a x Description feval a x evaluates polynomial a for the value of x If x is a vector or a matrix the evaluation is performed separately on each element and the result has the same size as x Example use classes p polynom 3 0 1 4 2 y feval p 1 5 y 2 46 242 770 1882 See also polynom polynom polynom inline feval ratfun ratfun Ratfun obj
221. ility note native functions for quaternions replace library quaternion which defined quaternion scalars and matrices It is much faster and supports arrays of more than two dimensions on the other hand matrix oriented functions are not supported anymore and the result of dumpvar is not directly compatible isquaternion Test for a quaternion Syntax b isquaternion q Description isquaternion q is true if the input argument is a quaternion and false otherwise Examples isquaternion 2 false isquaternion quaternion 2 true See also quaternion isnumeric q2mat Conversion from quaternion to rotation matrix Syntax R q2mat q 376 LyME User Manual 1999 2008 Calerga Sarl Description R q2mat q gives the 3x3 orthogonal matrix R corresponding to the rotation given by scalar quaternion q For a vector a x y z and its representation as a pure quaternion aq quaternion x y z the rotation can be performed with quaternion multiplication bq q aq q or matrix multiplication b Rxa Input argument q does not have to be normalized a quaternion cor responding to a given rotation is defined up to a multiplicative factor Example rpy2q 0 1 0 3 0 2 q2mat q R 0 9363 0 1688 0 3080 0 1898 0 9810 0 0954 0 2955 0 0954 0 9506 q quaternion 1 2 3 aq q 52281 2 0336j 2 7469k 1 2 3 a q R a q 1 a R See also q2rpy rpy2q q2rpy Conversion from quaternion to a
222. in square brackets and use commas to separate elements on the same row and semicolons to separate the rows themselves gt 1 2 5 3 ans 12 5 3 Column vectors are matrices with one column and row vectors are matrices with one row You can also use the colon operator to build a row vector by specifying the start and end values and optionally the step value Note that the end value is included only if the range is a multiple of the step Negative steps are allowed There are functions to create special matrices The zeros ones rand and randn functions create matrices full of zeros ones random num bers uniformly distributed between 0 and 1 and random numbers nor mally distributed with a mean of 0 and a standard deviation of 1 re spectively The eye function creates an identity matrix i e a matrix with ones on the main diagonal and zeros elsewhere All of these func tions can take one scalar argument n to create a square n by n matrix or two arguments m and n to create an m by n matrix Tutorial 19 ans 0 1386 0 9274 0 3912 0 8219 gt randn 2 ans 0 2931 1 2931 2 3011 0 9841 gt eye 3 ans 10 01 0 0 gt eye ans 0 1 0 0 1 2 3 Ors 0 0 You can use most scalar functions with matrices functions are applied to each element gt sin 1 2 ans 0 8415 0 9093 There are also functions which are specific to matrices For example det calculates the determinant of a square matr
223. ing parameter mu input can be a real array of any size and dimension The default value of mu is 255 The compressor and its inverse the expander are static nonlin ear filters used to improve the signal noise ratio of quantized signals The compressor should be used before quantization or on a signal represented with a higher precision See also ulLawexpand ja Lawcompress ulawexpand mu law expander 496 LyME User Manual 1999 2008 Calerga Sarl Syntax use sigenc output ulawexpand input output ulawexpand input mu Description ulawexpand input a expands signal input with mu law method us ing parameter a input can be a real array of any size and dimension The default value of mu is 255 See also ulawcompress alawexpand 4 9 wav wav is a library which adds to LME functions for encoding and decoding WAV files WAV files contain digital sound The wav library supports un compressed 8 bit and 16 bit monophonic and polyphonic WAV files It can also encode and decode WAV data in memory without files The following statement makes available functions defined in wav use wav wavread WAV decoding Syntax use wav samples samplerate nbits wavread filename samples samplerate nbits wavread filename n samples samplerate nbits wavread filename n1 n2 samples samplerate nbits wavread data Description wavread filename reads the WAV file filename The result is a 2
224. ingLe in this order only 2jsingle 3single 4isingle Command format is used to specify how numbers are displayed Strings Strings are stored as arrays usually row vectors of 16 bit unsigned numbers Literal strings are enclosed in single quotes Example of string The second string is empty For special characters the following es cape sequences are recognized 36 LyME User Manual 1999 2008 Calerga Sarl Character Escape seq Character code Null 0 0 Bell a 7 Backspace b 8 Horizontal tab t 9 Line feed n 10 Vertical tab v 11 Form feed f 12 Carriage return r 13 Single tick V 39 Single tick two 39 Backslash 92 Hexadecimal number xhh hh Octal number ooo 000 16 bit UTF 16 uhhhh unicode UTF 16 code For octal and hexadecimal representations up to 3 octal or 2 hex adecimal digits are decoded the first non octal or non hexadecimal digit marks the end of the sequence The null character can conve niently be encoded with its octal representation 0 provided it is not followed by octal digits it should be written 000 in that case It is an error when another character is found after the backslash Single ticks can be represented either by a backslash followed by a single tick or by two single ticks Depending on the application and the operating system strings can contain directly Unicode characters encoded as UTF 8 or MBCS multi byte character sequences 16 bit characte
225. inlinefun Examples fun2str sin sin fun2str inline x 2 y x y function y f x y y x 2xy See also info Information about LME Syntax info info builtin info functions info methods info variables info global info persistent info libraries info usedlibraries info size info threads str info SA info kind Description info displays the language version With an output argument the language version is given as a string info builtin displays the list of built in functions with their mod ule name modules are subsets of built in functions A letter u is displayed after each untrusted function functions which cannot be ex ecuted in the sandbox With an output argument info builtin 86 LyME User Manual 1999 2008 Calerga Sarl gives a structure array which describes each built in function with the following fields name function name module module name trusted true if the function is trusted info operators displays the list of operators With an output argument info operators gives a list of structures like info builtin info functions displays the list of user defined functions with the library where they are defined Parenthesis denote functions known by LME but not loaded they also indicate spelling errors in function or variable names With an output argument info functions gives a structure array which describes each user defined functio
226. input output 343 Example Count the number of lines and characters in a file fopen and fclose are not available in all LME applications fd fopen data txt lines 0 characters 0 while feof fd str fgets fd lines lines 1 characters characters length str end fclose fd See also ftell fflush Flush the input and output buffers Syntax fflush fd Description fflush fd discards all the data in the input buffer and forces data out of the output buffer when the device and their driver permits it fflush can be useful to recover from errors fgetl Reading of a single line Syntax line fgetl fd line fgetl fd n Description A single line of at most n characters is read from a text file The end of line character is discarded Upon end of file fgetl gives an empty string 344 See also fscanf fgets Reading of a single line fgets fd fgets fd n Description LyME User Manual 1999 2008 Calerga S rl A single line of at most n characters is read from a text file Unless the end of file is encountered before the end of line always a single line feed is preserved Upon end of file fgets gives an empty string See also format Default output format Syntax format format format format format format format format format format format format format format format format format format short short e short eng short g l
227. ion The function name is ignored inline expr returns an inline function with one implicit input ar gument and one result The input argument expr is a string which evaluates to the result The implicit input argument of the inline func tion is asymbol made of a single lower case letter different from i and j such as x or t which is found in expr If several such symbols are found the one closer to x in alphabetical order is picked inline expr argl returns an inline function with one re sult and the specified arguments arg1 etc These arguments are also given as strings Inline functions also accept an additional input argument which cor respond to fixed parameters provided when the function is executed inline funstr param where funstr is a string which contains the source code of a function stores param together with the function When the function is called param is prepended to the list of input arguments inline expr args paramstruct is a simplified way to create an inline function when the code consists of a single expression args is the names of the arguments which must be supplied when the inline function is called as strings paramstruct is a structure whose fields define fixed parameters inline expr true defines a function which can return as many output arguments as what feval or other functions which call the inline function expects Argument expr must be a function call itself Anonymous functions ar
228. ion of z and w Ar guments and result are real imaginary part is discarded Example betaln 0 5 2 0 2877 See also gammatn cast Type conversion Syntax Y cast X type Description cast X type converts the numeric array X to the type given by string type which can be double single int8 or any other signed or unsigned integer type char or logical The number value is preserved when possible conversion to integer types discards most significant bytes If X is an array conversion is performed on each element the result has the same size The imaginary part if any is discarded only with conversions to integer types Example cast pi int8 3int8 LME Reference mathematical functions 145 See also uint8 and related functions cdf Cumulative distribution function Syntax y cdf distribution x y cdf distribution x al y cdf distribution x al a2 Description cdf distribution x calculates the integral of a probability density function from oo to x The distribution is specified with the first argu ment a string case is ignored t and T are equivalent Additional arguments must be provided for some distributions The distributions are given in the table below Default values for the parameters when mentioned mean that the parameter may be omitted Distribution Name Parameters Beta beta aand b Cauchy cauchy a and b X ch
229. ion order follows the usual rules which state that the multiplication denoted with a star and division slash have a higher priority than the addition and subtraction You can change this order with parenthesis gt 24 3 4 ans 20 16 LyME User Manual 1999 2008 Calerga Sarl The result of expressions is automatically assigned to variable ans more about variables later which you can reuse in the next expres sion gt 3xans ans 60 Power is represented by the symbol gt 25 ans 32 LME has many mathematical functions Trigonometric functions as sume that angles are expressed in radians and sqrt denotes the square root gt sin pi 4 sqrt 2 ans 1 2 2 Complex Numbers In many computer languages the square root is defined only for non negative arguments However it is extremely useful to extend the set of numbers to remove this limitation One defines i such that i 1 and applies all the usual algebraic rules For instance 1 V i and 4 V4 1 2i Complex numbers of the form a bi are the sum of a real part a and an imaginary part b It should be mentioned that i the symbol used by mathematicians is called j by engineers LME accepts both symbols as input but it always writes it j You can use it like any function or stick an i or j after a number gt 2 3 j ans 2 3j gt 3j 2 ans 2 3j Many functions accept complex numbers as argument and return a complex
230. ions called directly or indirectly by statements in str The purpose of sandbox is to permit 102 LyME User Manual 1999 2008 Calerga Sarl the evaluation of code which comes from untrusted sources such as the Internet sandbox str varin evaluates the statements in string str ina context with local variables equal to the fields of structure varin With an output argument sandbox collects the contents of all vari ables in the fields of a single structure An error is thrown when the argument of sandbox attempts to exe cute one of the functions which are disabled This error can be caught by a try catch construct outside sandbox but not inside its argument so that unsuccessful attempts to circumvent the sandbox are always reported to the appropriate level Examples Evaluation of two assignments the second value is displayed and the variables are discarded at the end of the evaluation sandbox a 2 b 3 5 b 345 Evaluation of two assignments the contents of the variables are stored in structure result result sandbox a 2 b 3 5 result a 2 b real 1x3 Evaluation with local variables x and y initialized with the field of a structure Variable z is local to the sandbox in x 12 in y 1 10 sandbox z x y in Z 13 14 15 16 17 18 19 20 21 22 Attempt to execute the untrusted function fopen and to hide it from the outside Both attempts fail fopen is trapped and the security viol
231. iption text displays a string centered at the specified position Function sprintf can be used to create a string and display numbers Example The following code displays the string 1 2 3 7 centered around these coordinates x 1 2 y 3 7 text x y sprintf 1f 1f x y See also 3 35 Dialog Functions selectday Display a dialog for choosing a date 398 LyME User Manual 1999 2008 Calerga Sarl Syntax day selectday title day0 day selectday title Description selectday title day0 displays a dialog box which lets the user choose a date First input argument title is the title of the dialog box The day which is selected by default is day0 given as a vector of three integer numbers year month day with a single input argu ment the selected day is the current date The result is either a date as a 1 by 3 row vector or the empty array if the user taps the Cancel button Example birthday selectday Your birthday See also selecttime selecttime Display a dialog for choosing a time Syntax electtime title timed electtime title od nun Description selecttime title day0 displays a dialog box which lets the user choose a time First input argument title is the title of the dialog box The time which is selected by default is time0 given as a vector of two integer numbers hour minute where hour between 0 and 23 with a single input argument the selected time
232. irectory directorypath of volume volume Both ar guments are strings The directory path must be absolute it begins with a slash With an output argument vfsdir returns the result in a list of struc tures Each element corresponds to a file or a directory in the spec ified location Hidden elements are also included Structure fields include name the file or directory name a string and logical values for the element attributes readonly hidden system volumelabel directory archive and Link Example vfsdir Music classic Bach Brahms 5th mp3 ro See also vfsgetvolumes vfsmkdir vfsgetvolumes Get the list of volumes Syntax list vfsgetvolumes Description vfsgetvolumes gets the list of all volumes available on the handheld Volumes are identified by their name a string They are used with the path to identify a directory or a file in VFS Example vfsgetvolumes Music LME Reference VFS 367 See also vfsmkdir Make a new directory Syntax vfsmkdir volume path Description vfsmkdir volume path creates a new directory whose absolute path is path on volume volume Both arguments are strings Example vfsmkdir Music mp3 classic Bach See also vfsopen Open a VFS file Syntax fd fd vfsopen volume path vfsopen volume path mode Description vfsopen volume path opens the file whose absolute path is path on volume volum
233. ise For this way of handling arrays a single index is specified The first valid value of an index is always 1 The array whose ele ments are extracted is usually a variable but can be any expression an expression like 1 2 3 4 1 2 is valid and gives the 2nd element of the first row i e 3 In all indexing operations several indices can be specified simulta neously to extract more than one element along a dimension A single colon means all the elements along the corresponding dimension Instead of indices the elements to be extracted can be selected by the true values in a logical array of the same size as the variable the result is a column vector or in a logical vector of the same size as the corresponding dimension Calculating a boolean expression based on the variable itself used as a whole is the easiest way to get a logical array Variable indexing can be used in an expression or in the left hand side of an assignment In this latter case the right hand size can be one of the following An array of the same size as the extracted elements A scalar which is assigned to each selected element of the vari able An empty matrix which means that the selected elements should be deleted Only whole rows or columns or hyper planes for arrays of more dimensions can be deleted i e a 2 5 and b 3 6 8 if b is a row or column vector are legal while c 2 3 is not When indices are larger tha
234. itfield int32 bitfield double bitfield bitfield Cc H ee 4 6 filter filter is a library which adds to LME functions for designing analog continuous time and digital discrete time linear filters The following statement makes available functions defined in filter use filter This library provides three kinds of functions besselap buttap cheblap cheb2ap and ellipap which com pute the zeros poles and gain of the prototype of analog low pass filter with a cutoff frequency of 1 rad s They correspond respec tively to Bessel Butterworth Chebyshev type 1 Chebyshev type 2 and elliptic filters besself butter chebyl cheby2 and ellip which provide a higher level interface to design filters of these different types In addition to the filter parameters degree bandpass and band stop ripples one can specify the kind of filter lowpass highpass 456 LyME User Manual 1999 2008 Calerga Sarl bandpass or bandstop and the cutoff frequency or frequencies The result can be an analog or a digital filter given as a rational transfer function or as zeros poles and gain lp2lp lp2hp lp2bp and lp2bs which convert analog lowpass filters respectively to lowpass highpass bandpass and bandstop with specified cutoff frequency or frequencies Transfer functions are expressed as the coefficient vectors of their nu merator num and denominator den in decreasing powers of s Laplace transform for ana
235. ition number the more ill conditioned the inversion of the matrix Examples cond 1 0 0 1 1 cond 1 1 1 1 1le 3 4002 0008 See also conv Convolution or polynomial multiplication Syntax v conv v1 v2 M conv M1 M2 M conv M1 M2 dim Description conv vl v2 convolves the vectors v1 and v2 giving a vector whose length is length v1 length v2 1 The result is a row vector if both arguments are row vectors and a column vector if both arguments are column vectors Otherwise arguments are considered as matrices conv M1 M2 convolves the matrices M1 and M2 column by columns conv M1 M2 dim convolves along the dimension dim 1 for columns and 2 for rows If one of the matrices has only one column or one row it is repeated to match the size of the other argument Example conv 1 2 1 2 3 1476 conv 1 2 1 2 3 4 5 6 2 147 6 4 13 16 12 LME Reference linear algebra 193 See also conv2 Two dimensions convolution of matrices Syntax M M conv2 M1 M2 conv2 M1 M2 kind Description conv2 M1 M2 convolves the matrices M1 and M2 along both directions The optional third argument specifies how to crop the result Let nl1 ncl size M1 and nl2 nc2 size M2 With kind full default value the result M has nll1 nl2 1 lines and ncl nc2 1 columns With kind same the result M has nl1 lines and ncl columns this options is very useful if M1 represents equidistant sampl
236. iven as a cell array of power descending coefficient vectors the rows of the cell arrays correcpond to the outputs and their columns to the inputs See also Iti uminus Negative Syntax use lti b a b uminus a Description a multiplies all the outputs or all the inputs of system a by 1 If a is a transfer functions or a matrix of transfer functions this is equivalent to the unary minus See also ti minus ti uplus Iti uplus Negative Syntax use lti b a b uplus a Description a gives a See also Uti uminus lti plus 486 LyME User Manual 1999 2008 Calerga Sarl zpk LTI transfer function constructor using zeros and poles Syntax use lti a zpk z p k a zpk zeroslist poleslist gainlist a zpk TS a zpk TS var a zpk b a zpk b Description zpk creates transfer function LTI systems like tf tf Instead of using transfer function coefficients as input it accepts a vector of zeros a vector of poles and a gain for a simple input simple output SISO system or lists of sublists of zeros poles and gains for multiple input multiple output MIMO systems Examples use lti sd zpk 0 3 0 8 0 5j 0 8 0 5j 10 0 1 sd discrete time transfer function Ts 0 1 10z 3 z 2 1 6z 0 89 See also Iti bodemag Magnitude of the Bode plot Syntax use lti bodemag a bodemag a Description bodemag a plots th
237. ix gt det 1 2 5 3 ans 7 Arithmetic operations can also be applied to matrices with their usual mathematical behavior Additions and subtractions are performed on each element The multiplication symbol x is used for the product of two matrices or a scalar and a matrix gt 1 2 3 4 2 7 ans 16 34 20 LyME User Manual 1999 2008 Calerga Sarl The division symbol denotes the multiplication by the inverse of the right argument which must be a square matrix To multiply by the inverse of the left argument use the symbol This is handy to solve a set of linear equations For example to find the values of x and y such that x 2y 2 and 3x 4y 7 type gt 1 2 3 4 277 ans 3 0 5 Hence x 3 and y 0 5 Another way to solve this problem is to use the inv function which return the inverse of its argument It is sometimes useful to multiply or divide matrices element wise The and operators do exactly that Note that the and operators do not need special dot versions because they perform element wise anyway gt 1 2 3 4 x 2 1 5 3 ans 12 7 26 15 gt 1 2 3 4 2 1 5 3 ans 2 2 15 12 Some functions change the order of elements The transpose operator tick reverses the columns and the rows gt 1 2 3 4 5 6 ans 135 246 When applied to complex matrices the complex conjugate transpose is obtained Use dot tick if you just want to reverse the r
238. ix_elements Description A pair of brackets is used to define a 2 d array given by its elements or by submatrices The operator or spaces is used to separate elements on the same row and the operator or newline is used to separate rows Since the space is considered as a separator when it is in the direct scope of brackets it should not be used at the top level of expressions as long as this rule is observed each element can be given by an expression Inside brackets commas and semicolons are interpreted as calls to horzcat and vertcat Brackets themselves have no other effect than changing the meaning of commas semicolons spaces and new lines the expression 1 for instance is strictly equivalent to 1 The empty array is a special case Since horzcat and vertcat also accept cell arrays brackets can be used to concatenate cell arrays too Examples 110 LyME User Manual 1999 2008 Calerga Sarl Concatenation of two cell arrays C1 1 2 C2 ab false C1 C2 2x2 cell array Compare this with the effect of braces where elements are not con catenated but used as cells C1 C2 1x2 cell array See also Operator Braces Syntax list_elements cells v index v indexl index2 v index expr fun Vv i Description A pair of braces is used to define a list or a cell array given by its elements In a list the operator is used to separate elements I
239. l along the dimension of filtering The result y which has the same size as the input can be computed with the following code if u is a vector a a a l if length a gt length b b zeros 1 length a length b else a zeros 1 length b length a end length x LME Reference linear algebra 205 for i 1 length u y i b 1 u i x 1 for j 1 n 1 x j b j 1 u i x j 1 a j 1 y i end x n b n 1 u i a n 1 y i end The optional second output argument is set to the final state of the filter Examples filter 1 2 1 2 3 ones 1 10 1 1 2 4 1 11 22 8 47 121 5 6 5 6 5 6 5 p 0 8 filter 1 p 1 p u pxu 1 low pass with matching initial state 5 5 2 5 16 5 328 5 2624 5 4099 5 3279 u See also funm Matrix function Syntax Y funm X fun Y err funm X fun Description funm X fun returns the matrix function of square matrix X specified by function fun fun takes a scalar input argument and gives a scalar output It is either specified by its name or given as an inline function or a function reference With a second output argument err funm also returns an estimate of the relative error 206 LyME User Manual 1999 2008 Calerga Sarl Examples funm 1 2 3 4 sin 0 4656 0 1484 0 2226 0 6882 X 1 2 3 4 funm X inline 1 x 2 x 0 25 0 75 1 125 1 375 eye 2 X 2 eye 2 X 0 25 0 7
240. l and yl and y2 their outputs respectively append accepts any number of input arguments See also ti connect ss augstate Extend the output of a system with its states Syntax use lti b augstate a Description augstate a extends the ss object a by adding its states to its out puts The new output is y x where y is the output of a and x is its states See also Uti append Iti beginning First index Syntax use lti var beginning 470 LyME User Manual 1999 2008 Calerga Sarl Description In an expression used as an index between parenthesis beginning a gives the first valid value for an index It is always 1 See also ti end jlti subsasgn lti subsre Iti c2d Conversion from continuous time to discrete time Syntax se lti c2d a Ts c2d a Ts method u b b Description c2d a Ts converts the continuous time system a to a discrete time system with sampling period Ts c2d a Ts method uses the specified conversion method method is one of the methods supported by c2dm See also Iti connect Arbitrary feedback connections Syntax use lti b connect a links in out Libraries lti 471 Description connect a lLinks in out modifies lti object a by connecting some of the outputs to some of the inputs and by keeping some of the inputs and some of the outputs Connections are specified by the rows of matrix Link In each row the first
241. l bandstop filter with stopband between wl and wh relatively to half the sampling frequency With an additional input argument which is the string s besself gives an analog Bessel filter Frequencies are given in rad s See also bilinear Analog to digital conversion with bilinear transformation Syntax use filter zd pd kd bilinear zc pc kc fs numd dend bilinear numc denc fs Description bilinear zc pc kc fs converts the analog continuous time transfer function given by its zeros zc poles pc and gain kc to a digital discrete time transfer function given by its zeros poles and gain in the domain of the forward shift operator q The sampling frequency is fs Conversion is performed with the bilinear transormation Z 1 Zc 2fs 1l Z 2fs If the analog transfer function has less zeros than poles additional digital zeros are added at 1 to avoid a delay With three input arguments bilinear numc denc fs uses the coefficients of the numerators and denominators instead of their ze ros poles and gain 458 LyME User Manual 1999 2008 Calerga Sarl buttap Butterworth analog filter prototype Syntax use filter z p k buttap n Description buttap n calculates the zeros the poles and the gain of a Butter worth analog filter of degree n with a cutoff angular frequency of 1 rad s See also butter Butterworth filter Syntax use filter z k butter n w0 num
242. le X Y meshgrid 1 5 2 4 X 1 2 3 4 5 1 2 3 4 5 1 2 3 4 5 Y 22 2 2 2 3 3 3 3 3 4 4 4 4 4 Z atan2 X Y Z 0 4636 0 7854 0 9828 1 1071 1 1903 0 3218 0 5880 0 7854 0 9273 1 0304 0 2450 0 4636 0 6435 0 7854 0 8961 See also ndgrid Arrays of N dimension coordinates Syntax X1 Xn ndgrid x1 xn X1 Xn ndgrid x Description ndgrid x1 xn produces n arrays of n dimensions Array i is obtained by reshaping input argument i as a vector along dimension i and replicating it along all other dimensions to match the length of other input vectors All output arguments have the same size With one input argument ndgrid reuses it to match the number of output arguments 250 LyME User Manual 1999 2008 Calerga Sarl Y X ndgrid y x is equivalent to X Y meshgrid x y Example X1 X2 ndgrid 1 3 X1 1 1 1 2 2 2 3 3 3 X2 1 2 3 1 2 3 1 2 3 See also ndims Number of dimensions of an array Syntax n ndims A Description ndims A returns the number of dimensions of array A which is at least 2 Scalars row and column vectors and matrices have 2 dimen sions Examples ndims magic 3 2 ndims rand 3 4 5 3 See also nnz Number of nonzero elements LME Reference arrays 251 Syntax n nnz A Description nnz A returns the number of nonzero elements of array A See also find num2cell Conversion from numeric array to cell array
243. les findstr ababcdbaaab ab 13 10 findstr ababcdbaaab ac findstr aaaaaa aaa 123 See also 298 LyME User Manual 1999 2008 Calerga Sarl ischar Test for a string object Syntax b ischar obj Description ischar obj is true if the object obj is a character string false other wise Strings can have more than one line Examples ischar abc true ischar 0 false ischar false ischar true ischar abc def true See also isletter j1sspace isnumeric 1slogica isinteger jislist isstruct setstr isdigit Test for decimal digit characters Syntax b isdigit s Description For each character of string s isdigit s is true if it is a digit 0 to 9 and false otherwise LME Reference strings 299 Examples isdigit al23bAB12 FTTTFFFTTFF See also isletter Test for letter characters Syntax b isletter s Description For each character of string s isletter s is true if it is a letter and false otherwise Letters with diacritical signs are not considered as letters Examples isletter 2 a TTTTF bAB12 FFF See also isspace Test for space characters Syntax b isspace s Description For each character of string s isspace s is true if it is a space a tabulator a carriage return or a line feed and false otherwise 300 LyME User Manual 199
244. les eye 3 100 010 001 eye 2 3 100 010 eye 2 int8 2x2 int8 array 10 01 See also find Find the indices of the non null elements of an array Syntax ix find v s1 s2 find M s1 s2 x find M find n find n dir Description With one output argument find v returns a vector containing the indices of the nonzero elements of v v can be an array of any dimen sion the indices correspond to the internal storage ordering and can be used to access the elements with a single subscript With two output arguments find M returns two vectors contain ing the subscripts row in the first output argument column in the second output argument of the nonzero elements of 2 dim array M To obtain subscripts for an array of higher dimension you can convert the single output argument of find to subscripts with ind2sub With three output arguments find M returns in addition the nonzero values themselves in the third output argument With a second input argument n find limits the maximum number of elements found It searches forward by default with a third input argument dir find gives the n first nonzero values if dir is first or f andthe n last nonzero values if dir is last or UL 238 LyME User Manual 1999 2008 Calerga Sarl Examples ix find 1 2 0 0 3 6 ix 1 4 s1 s2 find 1 2 0 0 3 6 sl 1 2 S2 1 2 s1 s2 x find 1 2 0 0 3 6 sl 1 2 s2 2 6
245. literal num bers should be written with a type suffix such as 12int32 This is the only way to specify large 64 bit numbers because double precision floating point numbers have a mantissa of 56 bits uint64 and int64 are not supported on platforms with tight mem ory constraints Examples uint8 3 3uint8 3uint8 3uint8 uint8 50 50 400 1x8 uint8 array 50 100 150 200 250 44 94 144 int8 50 50 400 1x8 int8 array 50 100 106 56 6 44 94 112 LME Reference integers 275 See also intmax Largest integer Syntax intmax intmax type i i Description Without input argument intmax gives the largest signed 32 bit inte ger intmax type gives the largest integer of the type specified by string type which can be uint8 uint16 uint32 uint64 int8 int16 int32 or int64 64 bit integers are not sup ported on all platforms The result has the corresponding integer type Examples intmax 2147483647int32 intmax uint16 65535uint16 See also uint8 and related functions intmin Smallest integer Syntax intmin intmin type i i 276 LyME User Manual 1999 2008 Calerga Sarl Description Without input argument intmin gives the smallest signed 32 bit inte ger intmin type gives the largest integer of the type specified by string type which can be uint8 uint16 uint32 uint64 int8 int16 int32
246. loaded for objects of used defined classes Its definition should be have a header equivalent to function e C end obj i n where C is the name of the class obj is the object to be indexed i is the position of the index expression where end is used n is the total number of index expressions Examples Last 2 elements of a vector a 1 5 a end 1 end 45 Assignment to the last element of a vector a end 99 a 123499 Extension of a vector a end 1 100 a 123 4 99 100 See also Operator operator length global persistent Declaration of global or persistent variables Syntax global x y persistent xy LME Reference variables 49 Description By default all variables are local and created the first time they are assigned to Local variables can be accessed only from the body of the function where they are defined but not by any other function even the ones they call They are deleted when the function exits If the function is called recursively i e if it calls itself directly or indirectly distinct variables are defined for each call Similarly local variables defined in the workspace using the command line interface cannot be referred to in functions On the other hand global variables can be accessed by multiple functions and continue to exist even after the function which cre ated them exits Global variables must be declared with global in each functions which us
247. log filters or z z transform for digital filters or as the zeros z poles p and gain k besselap Bessel analog filter prototype Syntax use filter z p k besselap n Description besselap n calculates the zeros the poles and the gain of a Bessel analog filter of degree n with a cutoff angular frequency of 1 rad s See also besself Bessel filter Syntax use filter Zz k besself n w0 num den besself n w0 besself n wl wh besself n w0 high besself n wl wh stop as d besself 7 7S Libraries filter 457 Description besself calculates a Bessel filter The result is given as zeros poles and gain if there are three output arguments or as numerator and denominator coefficient vectors if there are two output arguments besself n w where w0 is a scalar gives a nth order digital low pass filter with a cutoff frequency of w0 relatively to half the sampling frequency besself n wl wh where the second input argument is a vector of two numbers gives a 2nth order digital bandpass filter with pass band between wl and wh relatively to half the sampling frequency besself n w0 high gives a nth order digital highpass filter with a cutoff frequency of w0 relatively to half the sampling frequency besself n wl wh stop where the second input argument is a vector of two numbers gives a 2nth order digita
248. lso audioset audioset Options for audio Syntax options audioset options audioset namel valuel options audioset options0 namel valuel Description audioset namel1 valuel creates the option argument used by audioplay Options are specified with name value pairs where the name is a string which must match exactly the names in the table below Case is significant Options which are not specified have a default value The result is a structure whose fields correspond to each option Without any input argument audioset creates a structure with all the default options Note that audioplay also interprets the lack of an option argument or the empty array as a request to use the default values When its first input argument is a structure audioset adds or changes fields which correspond to the name value pairs which fol low Here is the list of permissible options Name Default Meaning Repeat 1 number of repetitions SampleRate 44100 sample rate in Hz Default values may be different on platforms with limited audio ca pabilities Example Default options audioset Repeat 1 SampleRate 44100 See also audiop Lay Machine code 401 3 37 Machine Code Functions This chapter describes the functions which permit LyME to call arbi trary machine code This may be useful to access features which are not implemented directly in LyME such as direct calls to Palm OS func tions or support fo
249. m NetworkDB DATA netw ToDoDB DATA todo db dbdir LyME dumpvar db1 db 1 dbl struct name LyMELibDB type Lml creator LyME See also aqonumrec dbinfo Get info about a database LME Reference Palm database 359 Syntax s dbinfo dbName dbinfo dbName s Description dbinfo dbName gets the attributes of the database identified by its name dbName and returns them in a structure Atrributes are the same as options of dbset dbinfo dbName s changes the attributes database dbName with the fields of structure s Example dbinfo TestDB struct ReadOnly true See also dbset dbnewdb Create a new database Syntax dbnewdb dbName dbnewdb dbName type creator Description dbnewdb dbName creates a new database identified by its name dbName The four character type of the database is DATA and its four character creator is LyME The new database has no records dbnewrec can be used to populate it The second output argument if present specifies the database type and creator It is a string of two four characters codes separated by a slash Example Creation of a new database with type TEXT and creator test dbnewdb TestDB TEXT test 360 LyME User Manual 1999 2008 Calerga Sarl See also dbnewrec dbdeldb dbnewrec Create a new database record Syntax fd dbnewrec dbName fd index
250. me hello lme map atan2 1 2 3 0 4636 0 3218 S See also num2list Conversion from array to list Syntax list num2list A list num2list A dim Description num2list A creates a list with the elements of non cell array A num2list A dim cuts array A along dimension dim and creates a list with the result Examples num2list 1 5 1 2 3 4 5 num2list 1 2 3 4 1 2 3 4 num2list 1 2 3 4 1 1 2 3 4 312 LyME User Manual 1999 2008 Calerga Sarl num2list 1 2 3 4 2 1 3 2 4 See also replist Replicate a list Syntax listout replist listin n Description replist listin n makes a new list by concatenating n copies of list listin Example replist 1 abc 3 1 abc 1 abc 1 abc See also 3 21 Structure Functions cell2struct Convert a cell array to a structure array Syntax SA SA cell2struct CA fields cell2struct CA fields dim LME Reference structures 313 Description cell2struct CA fields converts a cell array to a structure array The size of the result is size SA 2 end where nf is the number of fields Field SA i1 i2 f of the result contains cell CA j i1 i2 where f is field field j Argument fields contains the field names as strings With a third input argument cell2struct CA fields dim picks fields of each element along dimension dim The size of the result is
251. mment comment spanning the whole line b comment after the continuation characters a a 3 no need to put spaces before the percent sign S percent characters in a string Comments may also be enclosed between and in that case they can span several lines Pragmas Pragmas are directives for LME compiler They can be placed at the same location as LME statements i e in separate lines or between semicolons or commas They have the following syntax _pragma name arguments where name is the pragma name and arguments are additional data whose meaning depends on the pragma Currently only one pragma is defined Pragmas with unknown names are ignored Name Arguments Effect line n Set the current line number to n _pragma line 120 sets the current line number as reported by er ror messages or used by the debugger or profiler to 120 This can be useful when the LME source code has been generated by process ing another file and line numbers displayed in error messages should refer to the original file 3 2 Function Call Functions are fragments of code which can use input arguments as parameters and produce output arguments as results They can be LME Reference 31 built in LME built in functions loaded from optional extensions or defined with LME statements user functions A function call is the action of executing a function maybe with input and or output arguments LME supports different s
252. mono tonically increasing or decreasing but they do not have to be spaced uniformly Interpolated points outside the input volume are set to nan Input and output data can be complex Imaginary parts of coordinates are ignored LME Reference arrays 243 The default interpolation method is multilinear An additional input argument can be provided to specify it with a string only the first character is considered Argument Meaning 0 or nearest nearest value LA Ve lower coordinates gt higher coordinates 1 or linear multilinear Method lt takes the sample where each coordinate has its in dex as large as possible lower or equal to the interpolated value and smaller than the last coordinate Method gt takes the sample where each coordinate has its index greater or equal to the interpo lated value When the method is followed by a scalar number extraval that value is assigned to all values outside the input volume i e extrapo lated values The default is NaN Examples One dimension interpolation interpn 1 2 5 8 0 1 0 2 0 5 1 0 2 3 7 nan 0 2000 0 3000 0 8333 interpn 1 2 5 8 0 1 0 2 0 5 1 2 3 7 0 nan 0 2000 0 2000 1 0000 Three dimension interpolation D cat 3 0 1 2 3 4 5 6 7 interpn 0 1 0 1 0 1 D 0 2 0 7 0 5 3 1000 Image rotation we define original coordinates between 0 5 and 0 5 in vector c and arrays X a
253. n den a gets the denominator of a as a row vector of descending power coefficients See also ratfun num ratfun ratfun ratfun diff Ratfun derivative Syntax use classes diff a Description diff a differentiates ratfun a Libraries classes 445 Example use classes r ratfun 1 3 0 1 2 5 q diff r 4x 3 21x 2 30x 2 4x 2 20x 25 a See also ratfun ratfun ratfun inline Conversion from ratfun to inline function Syntax use classes fun inline a Description inline a converts ratfun a to an inline function which can then be used with functions such as feval and ode45 See also ratfun ratfun ratfun feval ratfun feval Evaluate a ratfun object Syntax use classes y feval a x Description feval a x evaluates ratfun a for the value of x If x is a vector ora matrix the evaluation is performed separately on each element and the result has the same size as x 446 LyME User Manual 1999 2008 Calerga Sarl Example use classes r ratfun 1 3 0 1 2 5 y feval r 1 5 0 7143 2 3333 5 0000 8 6923 13 4000 See also ratfun ratfun Teval 4 4 ratio Library ratio implements the constructors and methods of class ratio for rational numbers It is based on long integers so that the precision is limited only by available memory Basic arithmetic operators and functions are overloaded to support expressions with the same syntax as for numbers
254. n with the following fields library library name name function name loaded true if loaded info methods displays the list of methods With an output argu ment info methods gives a structure array which describes each method with the following fields library library name class class name name function name loaded true if loaded info variables displays the list of variables with their type and size With an output argument info variables gives a structure array which describes each variable with the following fields name function name defined true if defined info global displays the list of all global variables With an output argument info global gives the list of the global variable names info persistent displays the list of all persistent variables With an output argument info persistent gives the list of the persis tent variable names info libraries displays the list of all loaded libraries With an output argument info libraries gives the list of the library names info usedlibraries displays the list of libraries available in the current context With an output argument info usedlibraries gives the list of the names of these libraries info size displays the size in bytes of integer numbers as used for indices and most internal computations and of pointers With LME Reference miscellaneous functions 87 an output argument info size gives them in a s
255. n 10 equally spaced intervals A second input argument may be used to specify the number of intervals The center of the intervals may be obtained in a second output argument Libraries stdlib 417 If Y is an array histograms are computed along the dimension spec ified by a third argument or the first non singleton dimension the re sult N has the same size except along that dimension When the second argument is a vector it specifies the centers of the intervals Example use stdlib N X hist logspace 0 1 5 N 45 21 14 11 9 X 1 9 3 7 5 5 7 3 9 1 ifftshift Shift DC frequency of FFT from center to beginning of spectrum Syntax use stdlib Y ifftshift X Description ifftshift X shifts halves of vector 1 d or matrix 2 d X to move the DC component from the center It should be used before ifft or ifft2 It reverses the effect of fftshift See also fftshift isreal Test for a real number Syntax use stdlib b isreal x 418 LyME User Manual 1999 2008 Calerga Sarl Description isreal x is true if x is a real scalar or a matrix whose entries are all real Examples use stdlib isreal 2 5 true isreal 2 3 2j false isreal exp pi 1j true See also 1snumeric isfloat 1sscalar linspace Sequence of linearly spaced elements Syntax use stdlib v linspace xl x2 v linspace xl x2 n Description Linspace x1 x2 produces a row vector of 100 values
256. n a cell array the operator is used to separate cells on the same row the operator is used to separate rows Braces without semicolons produce a list braces with semicolon s produce a cell array v index is the element of list variable v whose index is given index must be an integer between 1 for the first element and length v for the last element v index may be used in an expression to extract an element or on the left hand side of the equal sign to assign a new value to an element Unless it is the target of an assignment v may also be the result of an expression If vis a cell array v index is the element number index LME Reference operators 111 v index1 index2 gives the specified cell of a cell array v itself may be an element or a field in a larger variable provided it is a list i e complicated assignments like a 2 f 3 2 5 3 are accepted In an assignment when the index or indices are larger than the list or cell array size the variable is expanded with empty arrays In the list of the input arguments of a function call v is replaced with its elements v may be a list variable or the result of an expres sion Examples x 1 abc 3 5 7 1 x 1 string real 2x2 x 3 35 71 x 2 2 3j x 1 2 3j real 2x2 x 3 2 x 1 2 3j list x end 1 123 x 1 2 3j list 123 C 1 false ab magic 3 2x2 cell array C 2 1 ab a 1 3 5 fprintf
257. n as additional input arguments to the function specified by fun They permit to parame terize the ODE LME Reference non linear numerical functions 283 Van der Pol equation mu 1 Figure 3 1 Van der Pol equation with u 1 integrated with ode45 Example Let us integrate the following ordinary differential equation Van Der Pol equation parameterized by wu x u 1 x x x Let y x and y2 x their derivatives are yi y2 y u l yi y2 y and can be computed by the following function function yp f t y mu yp y 2 mux 1 y 1 2 y 2 y 1 The following ode45 call integrates the Van Der Pol equation from 0 to 10 with the default options starting from x 0 2 and x 0 0 with H 1 see Fig 3 1 t y ode45 f 0 10 2 0 1 The plot command expects traces along the second dimension con sequently the result of ode45 should be transposed plot t y 284 LyME User Manual 1999 2008 Calerga Sarl See also odeset Options for ordinary differential equation integration Syntax options odeset options odeset namel valuel options odeset options0 namel valuel Description odeset namel valuel creates the option argument used by ode23 and ode45 Options are specified with name value pairs where the name is a string which must match exactly the names in the table below Case is significant Options which are not specified have a de fa
258. n integer is required Argument out of range An argument is outside the permitted range of values Non scalar argument An argument is an array while a scalar number is required Non object argument An object is required as argument Not a permutation The argument is not a permutation of the integers from 1 ton Bad argument A numerical argument has the wrong site or the wrong value Unknown option A string option has an invalid value Object too large An object has a size larger than some fixed limit Undefined variable Attempt to retrieve the contents of a variable which has not been defined LME Reference 43 Undefined input argument Attempt to retrieve the contents of an input argument which was neither provided by the caller nor defined in the function Undefined function Attempt to call a function not defined Too few or too many input arguments Less or more arguments in the call than what the function accepts Too few or too many output arguments Less or more left side variables in an assignment than the function can return Syntax error Unspecified compile time error function keyword without function name Incomplete func tion header Bad function header Syntax error in a function header Missing expression Statement such as if or while without ex pression Unexpected expression Statement such as end or else followed by an expression Incomplete expression Additional elements were expected dur ing t
259. n the dimensions of the variable the vari able is expanded new elements are set to 0 for numeric arrays false for logical arrays the nul character for character array and the empty array for cell arrays Lists In LME lists have one dimension thus a single index is re quired Be it with a single index or a vector of indices indexed el ements are grouped in a list New elements also provided in a list can be assigned to indexed elements if the list to be assigned has a single element the element is assigned to every indexed element of the variable Cell arrays cell arrays are subscripted like other arrays The re sult or the right hand side of an assignment is also a cell array or a list for the syntax v select lists are to cell arrays what column vectors are to non cell arrays To create a single logical array for se lecting some elements function cellfun may be useful To remove LME Reference operators 107 cells the right hand side of the assignment can be the empty list or the empty array Structure arrays access to structure array fields combines sub scripting with parenthesis and structure field access with dot notation When the field is not specified parenthesis indexing returns a struc ture or structure array When indexing results in multiple elements and a field is specified the result is a value sequence Examples Ordering evaluation 14 2 3 9 Extracting a single element a row
260. name Objects must be created by the class constructor classname classname class strct classname parent1l makes an object of the specified class which inherits fields and methods from one or several other object s parent1 Parent objects are inserted as additional fields in the object with the same name as the class Fields of parent objects cannot be directly accessed by the new object s methods only by the parent s methods class object gives the class of object as a string The table below gives the name of native types 320 LyME User Manual 1999 2008 Calerga Sarl Class Native type double real complex or logical scalar or array char character or character array list list or structure inline inline function funref function reference Examples ol class struct fldl 1 fld2 rand 4 02 class struct fld3 abc c2 01 class o2 c2 See also isa Test for an object of a given class Syntax b isa object classname Description cl isa object classname returns true of object is an object of class class directly or by inheritance Example isa pi double true See also isobject Test for an object LME Reference logical functions 321 Syntax b isobject a Description object a returns true if a is an object created with class See also methods List of methods for a class Sy
261. nction without any argument which just displays a magic square the sum of each line and the sum of each column function magicsum3 magic_3 magic 3 sum_of_each_line sum magic_3 2 sum_of_each_column sum magic_3 1 You can call the function just by typing its name in the command line gt magicsum3 magic_3 816 357 492 sum_of_each_line sum_of_each_column 15 15 15 This function is limited to a single size For more generality let us add an input argument function magicsum n magc magic n sum_of_each_line sum magc 2 sum_of_each_column sum magc 1 When you call this function add an argument gt magicsum 2 magc 13 42 sum_of_each_line 4 6 sum_of_each_column 55 Tutorial 25 Note that since there is no 2 by 2 magic square magic 2 gives some thing else Finally let us define a function which returns the sum of each line and the sum of each column function sum_of_each_line sum_of_each_column magicSum n magc magic n sum_of_each_line sum magc 2 sum_of_each_column sum magc 1 Since we can obtain the result by other means we have added semi colons after each statement to suppress any output Note the upper case S in the function name for LME this function is different from the previous one To retrieve the results use the same syntax gt sl sc magicSum 3 15 15 15 You do not have to retrieve all the output arguments To get only the fi
262. nd Y and the image as a linear gradient between 0 and 1 c 0 5 0 01 0 5 X repmat c 101 1 Yea x phi 0 2 Xi cos phi X sin phi Y Yi sin phi X cos phi Y D 0 5 X E interpn c c D Xi Yi E isnan E 0 5 See also 244 LyME User Manual 1999 2008 Calerga Sarl intersect Set intersection Syntax c intersect a b c ia ib intersect a b Description intersect a b gives the intersection of sets a and b i e it gives the set of members of both sets a and b Sets are any type of nu merical character or logical arrays or lists or cell arrays of character strings Multiple elements of input arguments are considered as single members the result is always sorted and has unique elements The optional second and third output arguments are vectors of in dices such that if c ia ib intersect a b then c is a ia as well as b ib Example a a bc bbb de b z bc aa bbb c ia ib intersect a b C bbb bc ia 3 2 ib 4 2 a ia bbb bc b ib bbb bc Set exclusive or can also be computed as the union of a and b minus the intersection of a and b setdiff union a b intersect a b a aa de z See also setditt LME Reference arrays 245 ipermute Inverse permutation of the dimensions of an array Syntax B ipermute
263. nd the number of elements along each dimension of array A either in a row vector or as scalars if there are two output arguments or more size A i gives the number of elements in array A along dimen sion i size A 1 gives the number of rows and size A 2 the num ber of columns Examples M ones 3 5 size M 35 m See also sort Array sort Syntax A_sorted ix sort A A_sorted ix sort A dim A_sorted ix sort A dir A_sorted ix sort A dim dir list_sorted ix sort list list_sorted ix sort list dir Description sort A sorts separately the elements of each column of array A or the elements of A if it is a row vector The result has the same size as A Elements are sorted in ascending order with NaNs at the end For complex arrays numbers are sorted by magnitude LME Reference arrays 261 The optional second output argument gives the permutation array which transforms A into the sorted array It can be used to reorder elements in another array or to sort the rows of a matrix with respect to one of its columns as shown in the last example below Order of consecutive identical elements is preserved If asecond numeric argument dim is provided the sort is performed along dimension dim columns if dim is 1 rows if 2 etc An additional argument can specify the ordering direction It must be the string ascending or a for ascending order or descending or
264. ned 78 LyME User Manual 1999 2008 Calerga Sarl Example Here is the definition of operator plus so that it can be used with character strings to concatenate them function r plus a b if ischar a amp amp ischar b r a b else r builtin plus a b end The original meaning of plus for numbers is preserved 1 2 3 ab cdef abcdef See also eva clear Discard the contents of a variable Syntax clear clear vl v2 clear functions Description Without argument clear discards the contents of all the local variables including input arguments With string input arguments clear v1l v2 discards the contents of the enumerated variables Note that the variables are specified by strings clear is a normal function which evaluates its arguments if they are enclosed between parenthesis You can also omit parenthesis and quotes and use clear is usually not necessary because local variables are auto matically discarded when the function returns It may be useful if a large variable is used only at the beginning of a function or at the command line interface clear functions or clear f removes the definition of all func tions It can be used only from the command line interface not in a function LME Reference miscellaneous functions 79 Examples In the example below clear b evaluates its argument and clears the variable whose name is a clear b with
265. norm 1 sum abs V largest column sum of abs inf or inf max abs v largest row sum of abs inf min abs v largest row sum of abs p sum abs V p 1 p invalid fro sqrt sum abs v 2 sqrt sum diag M M Examples norm 3 4 5 norm 2 5 9 3 10 2194 norm 2 5 9 3 1 11 See also null Null space Syntax Z null A LME Reference linear algebra 219 Description null A returns a matrix Z whose columns are an orthonormal basis for the null space of m by n matrix A Z has n rank A columns which are the last right singular values of A that is those corresponding to the negligible singular values Example null 1 2 3 1 2 4 1 2 5 0 8944 0 4472 8 0581e 17 See also orth Orthogonalization Syntax Q orth A Description orth A returns a matrix Q whose columns are an orthonormal basis for the range of those of matrix A Q has rank A columns which are the first left singular vectors of A that is those corresponding to the largest singular values Example orth 1 2 3 1 2 4 1 2 5 0 4609 0 788 0 5704 8 9369e 2 0 6798 0 6092 See also 220 LyME User Manual 1999 2008 Calerga Sarl pinv Pseudo inverse of a matrix Description pinv M1 returns the pseudo inverse of matrix M For a nonsingular square matrix the pseudo inverse is the same as the inverse For an arbitrary matrix possibly nonsquare the pseudo inverse M2 has the following properties siz
266. nt a queue which contains scalar numbers The queue is stored in a global variable named QUEUE Elements are added at the front of the vector with function queueput and retrieved from the end of the vector with function queueget function queueput x global QUEUE QUEUE x QUEUE function x queueget global QUEUE x QUEUE end QUEUE end Both functions must declare QUEUE as global otherwise the variable would be local even if there exists also a global variable defined else where The first time a global variable is defined its value is set to the empty matrix In our case there is no need to initialized it to another value Here is how these functions can be used Tutorial 27 gt queueput 1 gt queueget ans 1 gt queueput 123 gt queueput 2 3j gt queueget ans 123 gt queueget ans 2 3j To observe the value of QUEUE from the command line interface QUEUE must be declared global there If a local variable already exists it is discarded gt global QUEUE gt QUEUE QUEUE gt queueput 25 gt queueput 17 gt QUEUE QUEUE 17 25 Chapter 3 LME Reference This chapter describes LME Lightweight Math Engine the interpreter for numerical computing used by Sysquake 3 1 Program format Statements An LME program or a code fragment typed at a command line is com posed of statements A statement can be either a simple expression a variable assignm
267. ntax methods classname list methods classname Description methods classname displays the list of methods defined for class classname Inherited methods and private methods are ignored With an output argument methods gives produces a list of strings See also 3 23 Logical Functions all Check whether all the elements are true Syntax v all A v all A dim b all v 322 LyME User Manual 1999 2008 Calerga Sarl Description all A performs a logical AND on the elements of the columns of array A or the elements of a vector If a second argument dim is provided the operation is performed along that dimension all can be omitted if its result is used by if or while because these statements consider an array to be true if all its elements are nonzero Examples all 1 2 3 2 false all 1 2 3 gt 0 true See also any Check whether any element is true Syntax v any A any A dim any v V b Description any A performs a logical OR on the elements of the columns of array A or the elements of a vector If a second argument dim is provided the operation is performed along that dimension Examples any 1 2 3 2 true any 1 2 3 gt 5 false See also LME Reference logical functions 323 bitall Check whether all the corresponding bits are true Syntax bitall A bitall A dim bitall v Vv V b Description bitall A performs a bitwi
268. ntinuous to discrete time conversion Syntax numd dend c2dm numc denc Ts dend c2dm numc denc Ts numd dend c2dm numc denc Ts method dend c2dm numc denc Ts method Ad Bd Cd Dd c2dm Ac Bc Cc Dc Ts method Description numd dend c2dm numc denc Ts converts the continuous time transfer function numc denc to a discrete time transfer function numd dend with sampling period Ts The continuous time transfer function is given by two polynomials in s and the discrete time 334 LyME User Manual 1999 2008 Calerga Sarl transfer function is given by two polynomials in z all as vectors of coefficients with highest powers first c2dm numc denc Ts method uses the specified conversion method method is one of zoh or z zero order hold default foh or f first order hold tustin or t Tustin bilinear transformation matched or m Matched zeros poles and gain The input and output arguments numc denc numd and dend can also be matrices in that case the conversion is applied separately on each row with the same sampling period Ts c2dm Ac Bc Cc Dc Ts method performs the conversion from continuous time state space model Ac Bc Cc Dc to discrete time state space model Ad Bd Cd Dd defined by dx ae Acx t Bcu t y t C x t Dc u t and x kK 1 Agx k Bgu k y k Cgx k Dau k Method matched is not supported for state space models Examples numd den
269. nts must be enclosed between parenthesis or square brackets if they are several One or more variable can be shared in the list of input and output arguments When the execution of the function terminates ei ther after the last statement or because of the command return the current value of the output arguments as set by the function s state ments is given back to the caller All variables used in the function s statements are local their value is undefined before the first assign ment and it is illegal to use them in an expression and is not shared with variables in other functions or with recursive calls of the same function Different kinds of variables can be declared explicitly with global and persistent When multiple functions are defined in the same code source for instance in a library the body of a function spans from its header to the next function or until the endfunction keyword whichever comes first Function definitions cannot be nested endfunction is required only when the function definition is followed by code to be executed outside the scope of any function This includes mixed code and function definitions entered in one large entry in a command line interface or applications where code is mainly provided as state ments but where function definitions can help and separate libraries are not wished note that libraries cannot contain code outside func tion definitions they do never require endfunction Like
270. o insure an accurate switching time Consider a first order filter with input u t where u t O for t lt 1 and u t 1 fort gt 1 The following function is defined for the state derivative function yp filterfun t y yp y t lt 1 0 1 290 LyME User Manual 1999 2008 Calerga Sarl Bouncing ball integrated with events 5 0 5 Figure 3 3 Bouncing ball integrated with events A single time event is generated at t 1 opt odeset EventTime inf 1 t y ode45 filterfun 0 5 0 opt plot t y Function filterfun is integrated in the normal way until t 1 inclu sive with u 0 This is why the conditional expression in filterfun is less than or equal to and not less than Then the event occurs and integration continues from t 1 with u 0 Non integrated state For the last example we will consider a system made of an integrator and a relay with hysteresis in a loop Let y 1 be the output of the integrator and y 2 the output of the relay Only y 1 is integrated An event occurs when the integrator is larger or smaller than the hys teresis value y 1 y 2 isTerminal false direction sign y 2 When the event occurs a new value is computed for the 2nd state LME Reference non linear numerical functions 291 Relay with hysteresis 1 Figure 3 4 Relay with hysteresis integrated with events yn y 2 To integrate this the following functions
271. o move the DC component to the center It should be used after fft or fft2 See also ifftshitt filter2 Digital 2 d filtering of data Syntax use stdlib Y filter2 F X Y filter2 F X shape Description filter2 F X filters matrix X with kernel F with a 2 d correlation The result has the same size as X An optional third argument is passed to conv2 to specify another method to handle the borders filter2 and conv2 have three differences arguments F and X are permuted filtering is performed with a correlation instead of a con volution i e the kernel is rotated by 180 degrees and the default method for handling the borders is same instead of full See also hankel Hankel matrix 416 LyME User Manual 1999 2008 Calerga Sarl Syntax use stdlib X hankel c r Description hankel c r creates a Hankel matrix whose first column contains the elements of vector c and whose last row contains the elements of vector r A Hankel matrix is a matrix whose antidiagonals have the same value In case of conflict the first element of r is ignored The default value of r is a zero vector the same length as c Example use stdlib hankel 1 3 3 1 2 8 3 4 5 6 23 45 6 7 3 4 5 67 8 See also diag hist Histogram Syntax use stdlib N X hist Y X hist Y m X hist Y m dim hist Y X hist Y X dim Description hist Y gives the number of elements of vector Y i
272. of value is written With an output argument dumpvar stores result into a string and produces no output LME Reference miscellaneous functions 81 Examples dumpvar 2 3 a i 6 dumpvar a a S 2 tapers dumpvar string s string abc See also error Display an error message and abort the current computation Syntax error str error format argl arg2 error identifier format argl arg2 Description Outside a try block error str displays string str as an error mes sage and the computation is aborted With more arguments error use the first argument as a format string and displays remaining argu ments accordingly like fprintf In a try block error str throws a user error without displaying anything An error identifier may be added in front of other arguments It is a string made of at least two segments separated by semicolons Each segment has the same syntax as variable or function name i e it begins with a letter or an underscore and it continues with letters digits and underscores The identifier can be retrieved with Lasterr or Lasterror in the catch part of a try catch construct and helps to identify the error For errors thrown by LME built in functions the first segment is always LME Examples error Invalid argument Invalid argument o ground error robot hit The robot is going to hit s o The robot is going to hit ground 82
273. on 67 Functions may be defined in separate files called libraries use makes them available in the current context so that they may be called by the functions or statements which follow Using a library does not make available functions defined in its sublibraries however libraries may be used multiple times in each context where their functions are referenced All use statements are parsed before execution begins They may be placed anywhere in the code typically before the first function 68 LyME User Manual 1999 2008 Calerga Sarl They cannot be skipped by placing them after an if statement Like wise try catch cannot be used to catch errors useifexists should be used if the absence of the library is to be ignored See also useifexists Import libraries if they exist Syntax useifexists lib useifexists libl lib2 Description useifexists has the same syntax and effect as use except that li braries which are not found are ignored without error See also while Loop controlled by a boolean expression Syntax while expr sl end Description The statements between the while statement and the corresponding end are executed repeatedly as long as the expression of the while statement yields true nonempty and all elements different from 0 and false If a break statement is executed in the scope of the while loop i e not in an enclosed loop the loop is terminated LME Reference debuggin
274. on A B returns the Kronecker product of matrices A size m1 by n1 and B size m2 by n2 i e an m1 m2 by n1 n2 matrix made of m1 by n1 submatrices which are the products of each element of A with B 210 LyME User Manual 1999 2008 Calerga Sarl Example kron 1 2 3 4 ones 2 1 2 1 2 1 2 3 4 3 4 WWrRre BRANN See also kurtosis Kurtosis of a set of values Syntax k k kurtosis A kurtosis A dim Description kurtosis A gives the kurtosis of the columns of array A or of the row vector A The dimension along which kurtosis proceeds may be specified with a second argument The kurtosis measures how much values are far away from the mean It is 3 for a normal distribution and positive for a distribution which has more values far away from the mean Example kurtosis rand 1 10000 1 8055 See also linprog Linear programming LME Reference linear algebra 211 Syntax x linprog c A b x linprog c A b xlb xub Description Linprog c A b solves the following linear programming problem mincx s t Ax lt b The optimum x is either finite infinite if there is no bounded solution or not a number if there is no feasible solution Additional arguments may be used to constrain x between lower and upper bounds linprog c A b xlb xub solves the following lin ear programming problem mincx s t Ax lt b X 2 Xib X lt Xub If xub is missing there is no upper bound
275. ong long e long eng long g int int int int int int bank ryt o0noxKxc a i LME Reference input output 345 format j format loose format compact Description format changes the format used by command disp and for output produced with expressions which do not end with a semicolon The following arguments are recognized Arguments Meaning none fixed format with 0 or 4 digits loose spacing short fixed format with 0 or 4 digits short e exponential format with 4 digits short eng engineering format with 4 digits short g general format with up to 4 digits long fixed format with 0 or 15 digits long e exponential format with 15 digits long eng engineering format with 15 digits long g general format with up to 15 digits int signed decimal integer int d signed decimal integer int u unsigned decimal integer int x hexadecimal integer int o octal integer int b binary integer bank fixed format with 2 digits for currencies orl for nonzero space for zero i symbol i to represent the imaginary unit j symbol j to represent the imaginary unit loose empty lines to improve readability compact no empty line Format for numbers for imaginary unit symbol and for spacing is set separately Format displays compactly numeric and boolean arrays positive numbers and complex numbers with a positive real part are displayed as negative numbers or complex numbers with a negative real part as p
276. opyPrevention false cannot be copied Hidden false hidden in the launcher OKToInstallNewer false if open the backup may install a newer db ReadOnly false cannot be modified Recyclable false deleted when closed or upon reset See also 3 27 Palm File Streaming Functions Palm OS provides a set of functions to simulate files on top of databases Function filestreamingopen is used to create or open these files Input output and control are done with the following generic functions LME Reference file streaming 363 Function Description fclose close the file feof check end of file status fflush flush I O buffers fgetl read a line fgets read a line fprintf write formatted data fread read data fscanf read formatted data fseek change the current I O position ftell get the current I O position fwrite write data redirect redirect output filestreamingopen Open a file Syntax fd filestreamingopen filename mode fd filestreamingopen filename mode creator fd filestreamingopen card filename mode fd filestreamingopen card filename mode creator Description filestreamingopen filename mode opens the file whose name is filename for reading and or writing Mode is a single character string whose meaning is described below Mode Meaning read only s w read write reset file contents u update keep file contents seek to beginning a add keep file contents seek to end filestr
277. or Example The error whose identifier is LME indexOutOfRange is handled by catch other errors are not try catch err lasterror if err identifier LME indexOutOfRange else 96 rethrow err end end See also lasterror try error str2fun Function reference Syntax funref str2fun str Description LyME User Manual 1999 2008 Calerga Sarl str2fun funref gives a function reference to the function whose name is given in string str It has the same effect as operator which is preferred when the function name is fixed Examples str2fun sin sin sin sin a cos str2fun a cos See also str2obj Convert to an object its string representation Syntax obj str2obj str LME Reference miscellaneous functions 97 Description str2obj str evaluates string str and gives its result It has the in verse effect as dumpvar with one argument It differs from eval by restricting the syntax it accepts to literal values and to the basic con structs for creating complex numbers arrays lists structures objects and other built in types Examples str2obj 1 2j 1 2j str dumpvar 1 abc 1 100 str 1 abc 1 100 str2obj str 1 abc real 1x100 eval str 1 abc real 1x100 str2obj sin 2 Bad argument str2obj eval sin 2 0 9093 See also varargin Remaining input a
278. or int64 64 bit integers are not sup ported on all platforms The result has the corresponding integer type Examples intmin 2147483648int32 intmin uint16 Quint16 See also uint8 and related functions map2int Mapping of a real interval to an integer type Syntax B map2int A B map2int A vmin vmax B map2int A vmin vmax type Description map2int A vmin vmax converts number or array A to 8 bit unsigned integers Values between vmin and vmax in A are mapped linearly to values 0 to 255 With a single input argument the default input interval is O to 1 map2int A vmin vmax type converts A to the specified type which can be any integer type given as a string uint8 uint16 uint32 uint64 int8 int16 int32 or int64 64 bit integers are not supported on all platforms The input interval is mapped to its full range In all cases input values outside the interval are clipped to the minimum or maximum values LME Reference non linear numerical functions 277 Examples map2int 0 2 0 2 1 2 1x5 uint8 array 0 51 102 153 204 255 255 map2int 1 3 7 0 10 uint16 1x3 uint16 array 6553 19660 45875 map2int 1 3 7 0 10 int16 1x3 int16 array 26214 13107 13107 See also uint8 and related functions 3 18 Non Linear Numerical Functions fminbnd Minimum of a function Syntax x y fminbnd fun x0 x y
279. otation of angle yaw around the z axis followed by a rotation of angle pitch around the y axis followed by a rotation of angle roll round the x axis All angles are given in radians The result is a normalized quaternion whose real part is cos 9 2 and imaginary part sin 9 2 Vxi vyj vzk for a rotation of 9 around unit vector Vx Vy vel The rotation is applied to a point xyz given as a pure quaternion a xi yj zk giving point a also as a pure quaternion then b q a q and a q b q The rotation can also be seen as changing coordinates from body to absolute where the body s attitude is given by pitch roll and yaw In order to have the usual meaning of pitch roll and yaw the x axis must be aligned with the direction of motion the y axis with the lateral direction and the z axis with the vertical direction with the usual sign conventions for cross products Two common choices are x pointing forward y to the left and z upward or x forward y to the right and z downward If input arguments are arrays of compatible size same size or scalar the result is a quaternion array of the same size conversion from angles to quaternion is performed independently on corresponding elements 382 LyME User Manual 1999 2008 Calerga Sarl Example Conversion of two vectors from aircraft coordinates x axis forward y axis to the left z axis upward to earth coordinates x directed to the north y to the west z to the zenith
280. out parenthesis and quotes does not evaluate it the argument is the literal string b a 2 b a clear a Undefined variable b a clear b b Undefined variable b b Fad a See also variable assignment deal Copy input arguments to output arguments Syntax v1 v2 deal e vl v2 deal el e2 Description With a single input argument deal provides a copy of it to all its output arguments With multiple input arguments deal provides them as output arguments in the same order deal can be used to assign a value to multiple variables to swap the contents of two variables or to assign the elements of a list to different variables Examples Swap variable a and b deal b a 80 LyME User Manual 1999 2008 Calerga Sarl Copy the same random matrix to variables x y and z x y z deal rand 5 Assign the elements of list l to variables v1 v2 and v3 l 1 abc 3 5 v1 v2 v3 deal l vl See also operator 1 dumpvar Dump the value of an expression as an assignment to a variable Syntax dumpvar value dumpvar name value dumpvar fd name value str dumpvar value str dumpvar name value Description dumpvar fd name value writes to the channel fd the standard out put by default a string which would set the variable name to value if it was evaluated by LME If name is omitted only the textual represen tation
281. ows and columns The flipud function flips a matrix upside down and fliptr flips a matrix left right gt flipud 1 2 3 4 ans 3 4 12 gt fliptr 1 2 3 4 ans 21 4 3 To sort the elements of each column of a matrix or the elements of a row vector use the sort function Tutorial 21 gt sort 2 4 8 7 1 3 ans 123478 To get the size of a matrix you can use the size function which gives you both the number of rows and the number of columns unless you specify which of them you want in the optional second argument gt size rand 13 17 ans 13 17 gt size rand 13 17 1 ans 13 gt size rand 13 17 2 ans 17 2 4 Polynomials LME handles only numerical values Therefore it cannot differenti ate functions like f x sin e However a class of functions has a paramount importance in numerical computing the polynomials Poly nomials are weighted sums of powers of a variable such as 2x 3x 5 LME which handles only matrices stores the coefficients of poly nomials in row vectors i e 2x 3x 5 is represented as 2 3 5 and 2x 3x as 2 0 0 0 3 0 Adding two polynomials would be like adding the coefficient vectors if they had the same size in the general case however you had better use the function addpol which can also be used for subtraction gt addpol 1 2 3 7 ans 49 gt addpol 1 2 2 4 5 ans 257 gt addpol 1 2 2 4 5 ans 2 3 3 M
282. part corresponds to the fraction of day after noon a fraction of 0 25 for instance is 18 00 or 6 P M The julian date is used by astronomers with GMT but using a local time zone is fine as long as an absolute time is not required cal2julian Calendar to julian date conversion LME Reference date conversion 371 Syntax jd cal2julian datetime jd cal2julian year month day jd cal2julian year month day hour minute second Description cal2julian datetime converts the calendar date and time to the julian date Input arguments can be a vector of 3 components year month and day or 6 components date and hour minute and sec onds or scalar values provided separately The result of clock can be used directly Example Number of days between October 4 1967 and April 18 2005 cal2julian 2005 4 18 cal2julian 1967 10 4 14624 See also julian2cal julian2cal Julian date to calendar conversion Syntax datetime julian2cal jd year month day hour minute second julian2cal jd Description julian2cal jd converts the julian date to calendar date and time With a single output the result is given a a row vector of 6 values for the year month day hour minute and second with more output arguments values are given separately Example Date 1000 days after April 18 2005 julian2cal cal2julian 2005 4 18 1000 2006 11 14 0 0 372 LyME User Manual 1999 2008 Calerga Sarl
283. pow x y Description realpow x y gives the real value of x to the power y The imaginary parts of x and y are ignored The result is NaN if it is not defined for the input arguments If the arguments are arrays their size must match or one of them must be a scalar number the power is performed element wise See also realsqrt Real square root Syntax y realsqrt x Description realsqrt x gives the real square root of x The imaginary part of x is ignored The result is NaN if x is negative Example realsqrt 1 0 1 10 1 2j nan 0 1 3 1623 1 See also rem Remainder of a real division Syntax r rem x y LME Reference mathematical functions 181 Description rem x y gives the remainder of x divided by y i e a number r be tween 0 and sign x abs y such that x q y r with integer q Imaginary parts if they exist are ignored Examples rem 10 7 3 rem 10 7 3 rem 10 7 3 rem 10 7 3 See also round Rounding to the nearest integer Syntax y round x Description round x gives the integer nearest to x If the argument is a complex number the real and imaginary parts are handled separately Examples round 2 3 2 round 2 6 3 round 2 3 2 See also ceil 182 LyME User Manual 1999 2008 Calerga Sarl sign Sign of a real number or direction of a complex number Syntax s sign x z2 sign z1 Description With a real argument sign
284. ption Between brackets the comma is used to separate elements on the same row in a matrix Elements can be scalars vector or matrices their number of rows must be the same unless one of them is an empty matrix Outside brackets or between parenthesis the comma is used to separate statements or the arguments of functions horzcat M1 M2 is equivalent to M1 M2 It can be used to rede fine this operator for objects Between braces the comma separates cells on the same row Examples 1 2 12 3 5 ones 2 311 511 abc def abcdef See also operator T operator 1 132 LyME User Manual 1999 2008 Calerga Sarl Operator Vertical matrix concatenation Syntax M1 M2 vertcat M1 M2 Description Between brackets the semicolon is used to separate rows in a matrix Rows can be scalars vector or matrices their number of columns must be the same unless one of them is an empty matrix Outside brackets the comma is used to separate statements they loose any meaning between parenthesis and give a syntax error vertcat M1 M2 is equivalent to M1 M2 It can be used to rede fine this operator for objects Between braces the semicolon separates rows of cells Examples 1 2 1 2 1 5 3 2 4 5 1 12345 32451 abc def abc def See also operator operator Operator Range Syntax x1 x2 x1l step x2 colon x1 x2 colon x1 step x2 LME Reference
285. put argument can be used to specify the type of the result It must be the string double single int8 int16 LME Reference arrays 253 int32 int64 uint8 uint16 uint32 or uint64 64 bit arrays are not supported on all platforms Example ones 2 3 111 111 ones 2 2x int32 nt32 array 2 1 1 PRE See also permute Permutation of the dimensions of an array Syntax B permute A perm Description permute A perm returns an array with the same elements as A but where dimensions are permuted according to the vector of dimensions perm It is a generalization of the matrix transpose operator perm must contain integers from 1 to n dimension perm i in A becomes dimension i in the result Example size permute rand 3 4 5 2 3 1 453 See also rand Uniformly distributed random number 254 LyME User Manual 1999 2008 Calerga Sarl Syntax x rand M rand n M rand nl1 n2 M rand nl n2 rand seed s Description rand builds a scalar pseudo random number uniformly distributed be tween 0 and 1 The lower bound O may be reached but the upper bound 1 is never The current implementation is based on a scalar 64 bit seed which theoretically allows 2 64 different numbers This seed can be set with the arguments rand seed s where s is a scalar or a vector of two components rand see
286. put argument is a vector of two numbers gives a 2nth order digital bandstop filter with stopband between wl and wh relatively to half the sampling frequency With an additional input argument which is the string s cheby2 gives an analog Chebyshev type 2 filter Frequencies are given in rad s See also ellip Elliptic filter 462 LyME User Manual 1999 2008 Calerga Sarl Syntax use filter z k ellip n w0 num den ellip n w0 ellip n wl wh ellip n w0 high ellip n wl wh stop ellip s Description ellip calculates a elliptic filter or Cauer filter The result is given as zeros poles and gain if there are three output arguments or as numerator and denominator coefficient vectors if there are two output arguments ellip n w0 where w0 is a scalar gives a nth order digital low pass filter with a cutoff frequency of w0 relatively to half the sampling frequency ellip n wl wh where the second input argument is a vector of two numbers gives a 2nth order digital bandpass filter with passband between wl and wh relatively to half the sampling frequency ellip n w0 high gives a nth order digital highpass filter with a cutoff frequency of w0 relatively to half the sampling frequency ellip n wl wh stop where the second input argument is a vector of two numbers gives a 2nth order digital bandstop filter with
287. put argument is numeric real or complex scalar vector or array and false otherwise Examples isnumeric pi true isnumeric abc false See also ischar isfloat isinteger isscalar isvector isprime Prime number test 170 LyME User Manual 1999 2008 Calerga Sarl Syntax b isprime n Description isprime n returns true if nis a prime number or false otherwise If n is a matrix the test is applied to each element and the result is a matrix the same size Examples use stdlib isprime 7 true isprime 0 2 10 FTF See also isscalar Test for a scalar number Syntax b isscalar x Description isscalar x is true if the input argument is scalar real or complex number of any floating point or integer type character or logical value and false otherwise Examples isscalar 2 true isscalar 1 2 5 false See also isnumeric jisvector size LME Reference mathematical functions 171 isvector Test for a vector Syntax b isvector x Description isvector x is true if the input argument is a row or column vec tor real or complex 2 dimension array of any floating point or inte ger type character or logical value with one dimension equal to 1 or empty array and false otherwise Examples isvector 1 2 3 true isvector 1 2 true isvector 7 true isvector 1 2 3 4 false See also tength Icm Least common multiple Synt
288. quaternion 0 4 0 1 0 2 0 2 0 4 0 11 0 2j 0 2k qinv q xe l 1 6 0 4i 0 8j 0 8k abs q 0 5 abs p 2 See also quaternion qnorm conj qnorm Quaternion scalar norm Syntax n qnorm q Quaternions 379 Description qnorm q gives the norm of quaternion q i e the sum of squares of its components or the square of its absolute value If q is an array of quaternions qnorm gives a double array of the same size where each element is the norm of the corresponding element of q See also quaternion labs qslerp Quaternion spherical linear interpolation Syntax q qslerp ql q2 t Description qslerp q1 q2 t performs spherical linear interpolation between quaternions ql and q2 The result is on the smallest great circle arc defined by normalized q1 and q2 for values of real number t between 0 and 1 If q1 or q2 is 0 the result is NaN If they are opposite the great circle arc going through 1 or 1i is picked If input arguments are arrays of compatible size same size or scalar the result is a quaternion array of the same size conversion from angles to quaternion is performed independently on corresponding elements Example q qslerp 1 rpy2q 0 1 1 5 0 0 33 0 66 1 roll pitch yaw q2rpy q roll 0 0000 0 1843 0 2272 0 0000 pitch 0 0000 0 3081 0 6636 1 0000 yaw 0 0000 0 4261 0 8605 1 5000 See also rpy2qj q2 rpy 380 LyME User Manual 1999 2008
289. r To transfer a library to another Palm device you can send it via infrared or Bluetooth Select Send in the File menu align your device to the destination device if you use infrared and tap the library to be sent in the list and select the transfer type if your device offers the choice The receiving device will display a dialog box asking if the library should be accepted if OK the library will be stored in the LyME database Another way to exchange libraries with the outside is to convert it to or from a Memo Pad note To export a library edit it Edit button then select Export in the File menu a new Memo Pad note is created To import a library create a new library Edit button then New then select Import in the File menu and choose the first line of one of the Memo Pad notes its entire contents will be inserted in the library At a lower level serialdevopen in addition to the physical serial ports whose list can be obtained with serialdevname accepts the four character codes of virtual serial drivers recognized by the Palm OS function SrmOpen Two codes are documented ircm for infrared and rfcm for Bluetooth in client mode To open a Bluetooth connec tion for instance you can use the code below serialdevopen will let the user pick a Bluetooth device from a list try fd serialdevopen rfcm functions like fread fwrite fprintf fscanf fgets fclose fd catch Bluetooth not supported or user
290. r 4 Libraries Libraries are collections of functions which complement the set of built in functions and operators of LME the programming language of LyME and Sysquake To use them type or add in the functions block of the SQ files which rely on them a use command such as use stdlib bitfield bitfield implements constructors and methods for bit fields binary numbers Standard operators are redefined to en able the use of amp and for bitwise operations and subscripts for bit extraction and assignment classes classes implements constructors and methods for poly nomial and rational functions With them you can use standard operator notations such as or ratio ratio implements constructors and methods for rational numbers based on long integers Standard arithmetic and boolean operators can be used constants constants defines common physical constants control control implements basic time and frequency domain responses for dynamical systems date date implements functions for date and time manipulation and conversion to and from strings filter filter provides functions for the design of analog and dig ital filters stat stat provides more advanced statistical functions stdlib stdlib is the standard library of general purpose functions for LME Functions span from array creation and manipulation to coordinates transform and basic statistics 410 LyME User Manual 1999 2008 Calerga Sarl 4 1 stdlib
291. r hardware Warning 1 Calling machine code is potentially dangerous It eas ily leads to crashes which may need soft or hard resets You should backup your device first The use of an emulator if available should be considered Warning 2 Presenting Palm device hardware and software archi tecture is far beyond the scope of this reference manual Warning 3 Functions described in this chapter are experimental and subject to change without notice 3 38 Introduction To support calls to machine code a new data type is provided binarydata Variables of this type contain a vector of 16 bit words Functions are provided to convert a string of hexadecimal digits or a vector of numbers to binarydata binarydata to a vector of integer numbers or a string of bytes and to execute as a machine code subroutine the contents of binarydata using another binarydata as data As an example we will develop a subroutine which fills some binarydata with the numbers n n 1 2 1 Before the subroutine is executed the following registers are set Register Value A5 Beginning of the data DO Length of the data in words Here is the code of the subroutine moveq w 0 dl loop tst w dO beq end move w dQ a5 d1 subq w 1 dO addq w 2 dl bra loop end rts The data offset of the next word to set is stored in D1 As long as DO is not 0 DO is stored in the data at offset D1 and decremented and D1 is 402 LyME User Manual 1999 20
292. r the codebook which has the same length An optional fourth input argument provides the tolerance the default is le 7 If only the predictor is required only the input and the predictor order must be supplied as input arguments See also Uoyds lloyds Optimal quantization Syntax use sigenc partition codebook partition codebook partition codebook lloyds input n lloyds input codebook0 lloyds tol Description Lloyds input n computes the optimal partition and codebook for quantizing signal input with n codes using the Lloyds algorithm If the second input argument is a vector Lloyds input codebook uses codebook as an initial guess for the codebook The result has the same length A third argument can be used to specify the tolerance used as the stopping criterion of the optimization loop The default is 1e 7 Example We start from a suboptimal partition and compute the distortion use sigenc partition codebook oly 0 1 2 0 5 0 5 2 494 LyME User Manual 1999 2008 Calerga Sarl in 5 0 6 3 i out dist quantiz in partition codebook dist 2 1421 The partition is optimized with Lloyds and the same signal is quan tized again The distortion is reduced partition_opt codebook_opt lloyds in codebook partition_opt 2 9 0 5 1 3 codebook_opt 4 1 1 7 0 4 2 2 i out dist quantiz in partition_opt codebook_opt dist 1 0543
293. rand 3 rPriwel Nw 0 5599 0 3074 0 5275 0 3309 0 8077 0 3666 0 7981 0 6424 0 6023 find A gt 0 7 2 last 7 5 See also flipdim Flip an array along any dimension Syntax B flipdim A dim Description flipdim A dim gives an array which has the same size as A but where indices of dimension dim are reversed LME Reference arrays 239 Examples flipdim cat 3 1 2 3 4 5 6 7 8 3 2x2x2 array 1 See also flipir Flip an array or a list around its vertical axis Syntax A2 fliplr A1 list2 fliplr list1 Description fliplr A1 gives an array A2 which has the same size as Al but where all columns are placed in reverse order fliplr list1 gives a list List2 which has the same length as list1 but where all top level elements are placed in reverse order Elements themselves are left unchanged Examples fliplr 1 2 3 4 21 43 fliplr 1 x 1 2 3 1 2 3 x 1 See also flipud Flip an array upside down 240 LyME User Manual 1999 2008 Calerga Sarl Syntax A2 flipud A1 Description flipud A1 gives an array A2 which has the same size as Al but where all lines are placed in reverse order Example flipud 1 2 3 4 4 3 12 See also ind2sub Conversion from single index to row column subscripts Syntax i j ind2sub size ind Description ind2sub size ind gives the subscripts of the element which would be retrieve
294. record Syntax dbdelrec dbName index dbdelrec dbName index delBackup Description dbdelrec dbName index deletes a record from the database identi fied by its name dbName The record itself is identified by its index the first record has index 0 With a third argument delBackup dbdelrec marks the record as deleted so that the record will also be deleted from the backup the next time the Palm device is synchronized See also dbdeldb dbnumrec dbdir List of databases 358 LyME User Manual 1999 2008 Calerga Sarl Syntax dbdir dbdir type dbdir type creator dblist dbdir Description dbdir displays the list of databases with their types and creators Types and creators are strings of four characters the type character izes the kind of data and the creator identifies the application which owns the database Without argument databases with type appl libr neti ovly or panl are not displayed To filter the databases which are displayed a string argument may be provided It contains the type and optionally a slash character and the creator The type or the creator can be replaced with the star character which stands for any value With an output argument dbdir returns a list of structures with fields name type and creator Examples dbdir DATA AddressDB DATA addr DatebookDB DATA date MailDB DATA mail MemoDB DATA memo ConnectionDB DATA mod
295. rection i lt 0 The event terminates integration if isterminal i is true The Events function is evaluated for each state obtained by integration intermediate time steps obtained by interpolation when Refine is larger than 1 are not considered When an event occurs the integration time step is reset to the initial value and new events are disabled during the next integration step to avoid shattering MaxStep should be used if events are missed when the result of Events is not monotonous between events When an event occurs function OnEvent is called if it exists It can be defined as function yn onevent t y i where i identifies the event stream positive for events produced by Events or negative for events produced by EventTime and the out put yn is the new value of the state immediately after the event The primary goal of ode functions is to integrate states However there are systems where some states are constant between events and are changed only when an event occurs For instance in a relay with hysteresis the output is constant except when the input over shoots some value In the general case ni states are integrated and n ni states are kept constant between events The total number of states n is given by the length of the initial state vector y0 and the number of integrated states ni is given by the size of the output of the integrated function Function OnEvent can produce a vector of size n to replace all
296. responds to an open file or device Cannot write to file Attempt to write to a read only file Bad seek Seek out of range or attempted on a stream file Too many open files Attempt to open too many files End of file Attempt to read data past the end of a file Timeout Input or output did not succeed before a too large amount of time elapsed No more OS memory The operating system cannot allocate more memory Bad context Call of a function when it should not application dependent Not supported The feature is not supported at least in the current version 3 7 Variable Assignment and Subscripting Variable assignment Assignment to a variable or to some elements of a matrix variable Syntax var expr varl var2 function Description var expr assigns the result of the expression expr to the variable var When the expression is a naked function call varl var2 function assigns the value of the output arguments of the function to the different variables Usually providing less variables than the function can provide just discards the superfluous output arguments however the function can also choose to perform in a different way an example of such a function is size which returns the number of rows and the number of columns of a matrix either as two numbers if there are two output arguments or as a 1 by 2 vector if there is a single output argument Providing more variables than what the fun
297. rguments Syntax function fun varargin l varargin Description varargin is a special variable which may be used to collect input ar guments In the function declaration it must be used as the last or unique input argument When the function is called with more argu ments than what can be assigned to the other arguments remaining ones are collected in a list and assigned to varargin In the body of the function varargin is a normal variable Its elements may be 98 LyME User Manual 1999 2008 Calerga Sarl accessed with the brace notation varargin i nargin is always the total number of arguments passed to the function by the caller When the function is called with fewer arguments than what is de clared varargin is set to the empty list Example Here is a function which accepts any number of square matrices and builds a block diagonal matrix function M blockdiag varargin M for block varargin block takes the value of each input argument m n size block M end 1 end m end 1 end n block end In the call below varargin contains the list ones 3 2 ones 2 3 blockdiag ones 3 2 ones 2 3 1 1 1 0 0 0 1 1 1 0 0 0 1 1 1 0 0 0 0 0 0 2 2 0 0 0 0 2 2 0 0 0 0 0 0 3 See also varargout Remaining output arguments Syntax function varargout fun varargout Description varargout is a special variable which may be used to dispatch output arguments In the
298. rialdevopen serialdevname 1 serialdevset BPS 19200 TextMode true Timeout 2 fprintf fd L d 2 n 1 reply fgetl fd fclose fd serialdevset Configuration settings for serial port Syntax options serialdevset options serialdevset namel valuel options serialdevset options0O namel valuel Description serialdevset namel valuel creates the option argument used by serialdevopen Options are specified with name value pairs where the name is a string which must match exactly the names in the table below Case is significant Options which are not specified have a default value The result is a structure whose Long integers 385 fields correspond to each option Without any input argument serialdevset creates a structure with all the default settings Note that serialdevopen also interprets the lack of an option argument or the empty array as a request to use the default values When its first input argument is a structure serialdevset adds or changes fields which correspond to the name value pairs which follow Here is the list of permissible options Name Default Meaning BPS 19200 bit per seconds Delay 0 delay after character output in seconds Handshake false hardware handshake StopBits 2 number of stop bits 1 1 5 or 2 TextMode false text mode Timeout 1 timeout in seconds Output operations wait for the specified delay after each character this can be
299. row gives a row vec tor of length size A 1 whose elements are the indices of each row It is equivalent to the range beginning end matrixrow is useful in boolean expressions to select some ele ments of an array matrixrow can be overloaded for objects of used defined classes Its definition should be have a header equivalent to function e C matrixrow obj i n where C is the name of the class obj is the object to be indexed i is the position of the index expression where matrixrow is used and n is the total number of index expressions See also matrixcoll beginning subsasgn Assignment to a part of an array list or structure 52 LyME User Manual 1999 2008 Calerga Sarl Syntax A subsasgn A s B Description When an assignment is made to a subscripted part of an object in a statement like A s1 s2 B LME executes A subsasgn A s B where subsasgn is a method of the class of variable A and s is a struc ture with two fields s type which is and s subs which is the list of subscripts sl s2 If a subscript is the colon character which stands for all elements along the corresponding dimensions it is represented with the string in s subs When an assignment is made to a subscripted part of an object in a statement like A s B LME executes A subsasgn A s B where subsasgn is a method of the class of variable A and s is a structure with two fields s type which is and s subs wh
300. rows of array x in a space of dimension size x 2 The result is an array with one more column Each row corresponds to a simplex values are row indices in x and give the vertices of each polyhedron The second output argument if requested is a logical vector with as many elements as rows in x elements are true if the corresponding point in x belongs to the convex hull of the set of points See also de launay tsearchn voronoin griddata Data interpolation in 2 d plane Syntax vi vi griddata x y v xi yi griddata x y v Xi yi method Description griddata x y v xi yi interpolates values at coordinates given by the corresponding elements of arrays xi and yi in a 2 dimension plane Original data are defined by corresponding elements of ar rays x y and v which must have the same size such that the value at coordinate x i y i is v i The result is an array with the same size as xi and yi where vi j is the value interpolated at xi j yi j All coordinates are real imaginary components are ignored Val ues v and vi can be real or complex The result for coordinates outside the convex hull defined by x and y is NaN griddata is based on Delaunay triangulation The interpolation method used in each triangle is linear by default or can be specified with an additional input argument a string 270 LyME User Manual 1999 2008 Calerga Sarl Argument Meaning 0 or nearest nearest value 1
301. rs encoded with uhhhh escape sequences are always accepted and handled correctly by all built in LME functions low level input output to files and devices which are byte oriented is an exception explicit UTF 8 conversion should be performed if necessary Lists and cell arrays Lists are ordered sets of other elements They may be made of any type including lists Literal lists are enclosed in braces elements are separated with commas 1 3 6 2 9 abc 1 xx Lists can be empty List s purpose is to collect any kind of data which can be assigned to variables or passed as arguments to functions Cell arrays are arrays whose elements or cells contain data of any type They differ from lists only by having more than one dimension LME Reference 37 Most functions which expect lists also accept cell arrays functions which expect cell arrays treat lists of n elements as 1 by n cell arrays To create a cell array with 2 dimensions cells are written between braces where rows are separated with semicolons and row elements with commas 1 abc 27 true Since the use of braces without semicolon produces a list there is no direct way to create a cell array with a single row or an empty cell array Most of the time this is not a problem since lists are accepted where cell arrays are expected To force the creation of a cell array the reshape function can be used reshape ab cde 1 2 S
302. rst one just type gt sl magicSum 3 Sl 15 15 15 When you retrieve only one output argument you can use it directly in an expression gt magicSum 3 3 ans 18 18 18 One of the important benefits of defining function is that the variables have a limited scope Using a variable inside the function does not make it available from the outside thus you can use common names such as x and y without worrying about whether they are used in some other part of your whole program For instance let us use one of the variables of magicSum gt mage 77 magc 77 26 LyME User Manual 1999 2008 Calerga Sarl gt magicSum 3 magc ans 92 92 92 gt magc magc 77 2 9 Local and Global Variables When a value is assigned to a variable which has never been refer enced a new variable is created It is visible only in the current con text the base workspace for assignments made from the command line interface or the current function invocation for functions The variable is discarded when the function returns to its caller Variables can also be declared to be global i e to survive the end of the function and to support sharing among several functions and the base workspace Global variables are declared with keyword global global x global y z A global variable is unique if its name is unique even if it is declared in several functions In the following example we define functions which impleme
303. rwise or b1 b2 is equivalent to b1 b2 It can be used to redefine this operator for objects Example false false true true false true false true FTTT See also 130 LyME User Manual 1999 2008 Calerga Sarl Operator Or with lazy evaluation Syntax b1 b2 Description b1 b2 is b1 if b1 is true and b2 otherwise Like with if and while statements b1 is true if it is a nonempty array with only non zero elements b2 is evaluated only if b1 is false b1 b2 bn returns the last operand which is true remaining operands are not evaluated or the last one Example Boolean value which is true if the vector v is empty or if its first ele ment is NaN isempty v isnan v 1 See also operator 6 Operator Alternative with lazy evaluation Syntax b x y Description b x y is x if b is true and y otherwise Like with if and while state ments b is true if it is a nonempty array with only non zero elements Only one of x and y is evaluated depending on b Operators and have the same priority parenthesis or brackets should be used if e g x or y is a range LME Reference operators 131 Example Element of a vector v or default value 5 if the index ind is out of range ind lt 1 ind gt length v 5 v ind See also operator amp amp operator Operator Horizontal matrix concatenation Syntax M1 M2 M1 M2 horzcat M1 M2 Descri
304. s 362 3 28 Palm VFS Functions 0 0 000 000 eee eee 364 3 29 Time Functions ee raniona nitnama ee ee 368 3 30 Date Conversion Functions 0005 370 3 31 QUATEMIONS ee gs eee Re ee whee eA ha es 372 3 32 Serial Port Functions 0 00 00 eee 382 3 33 Long Integers ioe k ea eh ewes ee eee ee ee ES 385 3 34 LyME Functions 20 00 0002 387 3 35 Dialog Functions 0 000 000 ee eee 397 3 36 Audio output 00 0000 00 ee ee 399 3 37 Machine Code Functions 00 00008 401 ahd Bde at ks You eyes ae Bk eet ea Ate ee 401 3 39 FUNCHONS ss se nasser tranta kaap REG 402 409 AD StdiBi a eag 4 d ee a eee a Ra E ae a 410 42 State cee eke ee a a a a ee G O ee we E es 426 ASS e EEE EEE E EE TEE E E E 437 44 ATO ae bee nde ines Fe a o A e e a aaa a e sed 446 4 5 bitfield 0 00 ce es 449 DS wd tad bd Ao ade bh Ae Gee we 455 AD MI seek ie te quae dane amp Lee eGR A doh Whee a wee LRA 465 4 8 sigenc 2 2 0 ce a a a a 490 4 9 Wavy ee 496 Qa ied amp edge ae eh ik Gon bette eh a 498 4 11 constants ee 501 502 Chapter 1 Using LyME LyME is a port of LME Lightweight Math Engine the heart of Sysquake to Palm OS handheld devices It implements about 320 native commands functions and operators mostly compatible with Matlab It requires Palm OS 3 1 or higher and at least 1 MBytes of memory free 1 1 LyME Installation
305. s use stat nanmean 1 2 nan nan 6 7 147 nanmean 1 2 nan nan 6 7 2 1 5 6 5 nanmean nan nan nan See also nanmedian Median after discarding NaNs Syntax use stat y nanmedian A y nanmedian A dim 432 LyME User Manual 1999 2008 Calerga Sarl Description nanmedian v gives the median of vector v i e the value x such that half of the elements of v are smaller and half of the elements are larger NaN values are ignored nanmedian A gives a row vector which contains the median of the columns of A With a second argument nanmedian A dim operates along dimension dim See also nanstd Standard deviation after discarding NaNs Syntax use stat y nanstd A y nanstd A p y nanstd A p dim Description nanstd v returns the standard deviation of vector v with NaN values ignored normalized by one less than the number of non NaN values With a second argument nanstd v p normalizes by one less than the number of non NaN values if p is true or by the number of non NaN values if p is false nanstd M gives a row vector which contains the standard devi ation of the columns of M With a third argument nanstd M p dim operates along dimension dim In all cases NaN values are ignored Example use stat nanstd 1 2 nan nan 6 7 10 11 12 6 3640 4 5092 3 5355 See also Libraries stat 433 nansum Sum after discarding NaNs Syntax use stat y nansum A y nansum A dim D
306. s by cropping or by padding with zeros fft2 f nr nc resizes first dimension to nr rows and second dimension to nc columns In fft2 f size the new size is given as a two element vector nr nc fft2 F n is equivalent to fft2 F n n If the first argument is an array with more than two dimensions fft2 performs the 2 d DFT along dimensions 1 and 2 separately for each plane along remaining dimensions fftn performs an DFT along each dimension See also fftn n dimension Fast Fourier Transform 204 LyME User Manual 1999 2008 Calerga Sarl Syntax F fftn f F fftn f size Description fftn f returns the n dimension Discrete Fourier Transform of array f DFT along each dimension of f With two input arguments fftn f size resizes f by cropping or by padding f with zeros See also filter Digital filtering of data Syntax filter filter filter y xf f X0 X0 dim y b a u y b a u y b a u ilter Description filter b a u filters vector u with the digital filter whose coefficients are given by polynomials b and a The filtered data can also be an array filtered along the first non singleton dimension or along the dimension specified with a fifth input argument The fourth argu ment if provided and different than the empty matrix is a ma trix whose columns contain the initial state of the filter and have max length a length b 1 element Each column correspond to a signa
307. s discarded The complementary error function is defined as erfc x 1 erf x edt x Example erfc 1 0 1573 See also erfinv Inverse error function Syntax x erfinv y Description erfinv y gives the value x such that y erf x Argument and result are real imaginary part is discarded y must be in the range 1 1 values outside this range give nan Example y erf 0 8 y 0 7421 erfinv y 0 8 LME Reference mathematical functions See also exp Exponential Syntax y exp x Description exp x is the exponential of x i e 2 7182818284590446 Example exp 0 1 0 5j pil 1 2 7183 1j See also expm1 Exponential minus one Syntax y expml1 x Description expm1 x is exp x 1 with improved precision for small x Example expm1 le 15 le 15 exp le 15 1 1 1102e 15 157 158 LyME User Manual 1999 2008 Calerga Sarl See also factor Prime factors Syntax v factor n Description factor n gives a row vector which contains the prime factors of n in ascending order Multiple prime factors are repeated Example factor 350 2 5 5 7 See also factorial Factorial Syntax y factorial n Description factorial n gives the factorial n of nonnegative integer n If the input argument is negative or noninteger the result is NaN The imag inary part is ignored Examples factorial 5 120 factorial 1 0 1 2 3 3 14
308. s mathe matical arithmetic operations like the addition and the multiplication 104 LyME User Manual 1999 2008 Calerga Sarl They can be infix Such as x y separating their two arguments called operands prefix such as x placed before their unique operand or postfix such as M placed after their unique operand In Sysquake their arguments are always evaluated from left to right Since they do not require parenthesis or comma their priority matters Priority specifies when subexpressions are considered as a whole as the argu ment of some operator For instance in the expression a b c where x denotes the multiplication the evaluation could result in a b c or at b c however since operator s priority is higher than operator s the expression yields a b c without ambiguity Here is the list of operators from higher to lower priority L d A A unary J of lt lt gt lt SS SS Most operators have also a functional syntax for instance a b can also be written plus a b This enables their overriding with new definitions and their use in functions such as feval which take the name of a function as an argument Here is the correspondence between operators and functions LME Reference operators 105 a b vertcat a b a b minus a b a b horzcat a b axb mtimes a b a b colon a b a b mrdivide a b a b c colon a b c a b mldivide a b alb or a b
309. s more bits than the target integer most significant bits are ignored Example use bitfield a bitfield 9 4 a 0x1001 i int8 a 210 b bitfield i 0b11111001 See also t uint32 bitfield int8 bitfield int16 bitfield int32 bitfield doubLle bitfield bitfield Cc H ee bitfield length Word length of a bitfield Syntax use bitfield wordlength length a Description Llength a gives the number of bits of bitfield a 454 LyME User Manual 1999 2008 Calerga Sarl Example use bitfield a bitfield 123 16 Llength a 16 See also bitfield sign Get the sign of a bitfield Syntax use bitfield s sign a Description Sign a gets the sign of bitfield a The result is 1 if the most significant bit of a is 1 0 if all bits of a are 0 or 1 otherwise Example use bitfield a bitfield 5 3 a 0b101 sign a 1 See also bitfield uint8 bitfield uint16 bitfield uint32 Convert a bitfield object to an unsigned integer number Libraries filter 455 Syntax use bitfield n uint8 a n uint16 a n uint32 a Description uint8 a uint16 a and uint32 a convert bitfield a to a uint8 uint16 or uint32 number respectively If a has more bits than the target integer most significant bits are ignored Example use bitfield a bitfield 1234 16 uint8 a 210 See also t uint32 bitfield int8 bitfield intl6 b
310. se conjugate transpose element wise equality horizontal array concatenation N left division element wise inequality difference matrix left division matrix right division matrix multiplication addition division multiplication transpose unary minus unary plus vertical array concatenation Most of these operators work as expected like with complex scalars and matrices Multiplication and left right division are not commuta tive Matrix operations are not supported operators x and are defined as a convenience they are equivalent to and respectively and work only element wise with scalar arguments Mathematical functions below accept quaternions as arguments with arrays of quaternions they are applied to each element sepa rately Function Purpose abs absolute value conj conjugate cos cosine exp exponential log natural logarithm real real part sign quaternion sign normalization Sin sine sqrt square root Functions below performs computations on arrays of quaternions 374 Function cumsum diff double mean sum LyME User Manual 1999 2008 Calerga Sarl Purpose cumulative sum differences conversion to array of double arithmetic mean sum Functions below are related to array size Function beginning cat end flipdim fliplr flipud ipermute isempty length ndims numel permute repmat reshape rot90 size squeeze
311. se AND on the elements of the columns of array A or the elements of a vector If a second argument dim is provided the operation is performed along that dimension A can be a double or an integer array For double arrays bitall uses the 32 least significant bits Examples bitall 5 3 1 bitall 7uint8 6uint8 3uint8 6uint8 2 2x1 uint8 array 6 2 See also bitany al l bitand bitand Bitwise AND Syntax c bitand a b Description Each bit of the result is the binary AND of the corresponding bits of the inputs The inputs can be scalar arrays of the same size or a scalar and an array If the input arguments are of type double so is the result and the operation is performed on 32 bits 324 LyME User Manual 1999 2008 Calerga Sarl Examples bitand 1 3 1 bitand 1 6 1 1031010 bitand 7uint8 1234int16 2int16 See also bitany Check whether any of the corresponding bits is true Syntax v v b bitany A bitany A dim bitany v Description bitany A performs a bitwise OR on the elements of the columns of array A or the elements of a vector If a second argument dim is provided the operation is performed along that dimension A can be a double or an integer array For double arrays bitany uses the 32 least significant bits Examples bitany 5 3 7 bitany Quint8 6uint8 3uint8 6uint8 2 2x1 uint8 array 6 7 See also bitcmp Bit complement bitwise NOT L
312. size of the other operand ldivide x y is equivalent to x y It can be used to redefine this operator for objects Example 1 2 3 10 11 12 10 5 5 4 See also LME Reference operators Operator Matrix power Syntax x y M k x 7M mpower x y Description x y calculates x to the y power provided that either both operands are scalar 119 the first operand is a square matrix and the second operand is an integer or the first operand is a scalar and the second operand is a square matrix Other cases yield an error mpower x y is equivalent to x y It can be used to redefine this operator for objects Examples 2 3 8 1 2 3 4 2 7 10 15 22 2 1 2 3 4 10 4827 14 1519 21 2278 31 7106 See also Operator Scalar power 120 LyME User Manual 1999 2008 Calerga Sarl Syntax M1 M2 x M M x power x y Description M1 M2 calculates M1 to the M2 power element wise Both arguments must have the same size unless one of them is a scalar power x y is equivalent to x y It can be used to redefine this operator for objects Examples 1 2 3 4 2 1 4 9 16 1 2 3 5 4 3 1 16 27 See also Operator Complex conjugate transpose Syntax M ctranspose M Description M is the transpose of the real matrix M i e columns and rows are per muted If M is complex the result is the complex conjugate transpose of M
313. so is the result and the operation is performed on 32 bits Examples bitor 1 2 3 bitor 1 6 1 133557 bitor 7uint8 1234int16 1239int16 See also bitset Bit assignment LME Reference logical functions 327 Syntax b bitset a n b bitset a n v Description bitset a n sets the n th bit of integer a to 1 a can be an integer or a double The result has the same type as a n 1 corresponds to the least significant bit With 3 input arguments bitset a n v sets the bit to 1 if v is nonzero or clears it if v is zero The inputs can be scalar arrays of the same size or a mix of them If ais of type double so is the result and n is limited to 32 Examples bitset 123 10 635 bitset 123 1 0 122 bitset 7uint8 1 8 1x8 uint8 array 7 7 7 15 23 39 71 135 See also bitshift Bit shift Syntax b bitshift a shift b bitshift a shift n Description The first input argument is converted to a 32 bit unsigned integer and shifted by shift bits to the left if shift is positive or to the right if it is negative With a third argument n only n bits are retained The inputs can be scalar arrays of the same size or a mix of both 328 LyME User Manual 1999 2008 Calerga Sarl Examples bitshift 1 3 8 bitshift 8 2 2 2 4 8 16 32 bitshift 15 0 3 4 15 14 12 8 See also bitxor Bitwise exclusive OR Syntax c bitxor a b Description The input arguments are conv
314. spaced linearly from x1 and x2 inclusive With a third argument Linspace x1 x2 n produces a row vector of n values Examples use stdlib Linspace 1 10 1 0000 1 0909 1 1818 9 9091 10 0000 Linspace 1 2 6 1 0 1 2 1 4 1 6 1 8 2 0 See also Libraries stdlib 419 logspace Sequence of logarithmically spaced elements Syntax use stdlib v logspace xl x2 v logspace xl x2 n Description logspace x1 x2 produces a row vector of 100 values spaced log arithmically from 10 x1 and 10 x2 inclusive With a third argument Logspace x1 x2 n produces a row vector of n values Example logspace 0 1 1 0000 1 0235 1 0476 9 5455 9 7701 10 0000 See also inspace operator median Median Syntax use stdlib Xx median v Vv median M v median M dim Description median v gives the median of vector v i e the value x such that half of the elements of v are smaller and half of the elements are larger median M gives a row vector which contains the median of the columns of M With a second argument median M dim operates along dimension dim 420 LyME User Manual 1999 2008 Calerga Sarl Example use stdlib median 1 2 5 6 inf 5 See also perms Array of permutations Syntax use stdlib M perms v Description perm v gives an array whose rows are all the possible permutations of vector v Example use stdlib perms 1 3 RPFNFRN WW NrPWWReN WWNRNF
315. specified for the call of the anony mous function as if a direct call was performed Anonymous functions are a convenient way to provide the glue be tween functions like fzero and ode45 and the function they accept as argument Additional parameters can be passed directly in the anony mous function with captured variables instead of being supplied as additional arguments the code becomes clearer LME Reference mathematical functions 135 Examples Function reference quad sin 0 pi 2 Anonymous function a 2 fun x sin a x fun 3 0 2794 quad fun 0 2 0 8268 Without anonymous function parameter a should be passed as an additional argument after all the input arguments defined for quad including those which are optional when parameters are missing quad inline sin a x x a 0 2 false a 0 8268 Anonymous functions are actually stored as inline functions with all captured variables dumpvar fun inline function y f a x y sin a x 2 Anonymous function with multiple output arguments fun A size A s fun ones 2 3 3 fun ones 2 3 Wi nNnNion il See also 3 13 Mathematical Functions abs Absolute value 136 LyME User Manual 1999 2008 Calerga Sarl Syntax x abs z Description abs takes the absolute value of each element of its argument The result is an array of the same size as the argument each element is non negati
316. sr s Sin 2 pi 740 x t wavwrite map2int s 1 1 int16 sr 16 beep wav 498 LyME User Manual 1999 2008 Calerga Sarl See also Wwavread 4 10 date date is a library which adds to LME functions to convert date and time between numbers and strings The following statement makes available functions defined in date use date datestr Date to string conversion use date str datestr datetime str datestr date format Description datestr datetime converts the date and time to a string The input argument can be a vector of 3 to 6 elements for the year month day hour minute and second a julian date as a scalar number or a string which is converted by datevec The result has the following format jj mmm yyyy HH MM SS where jj is the two digit day mmm the beginning of the month name yyyy the four digit year HH the two digit hour MM the two digit minute and SS the two digit second The format can be specified with a second input argument When datestr scans the format string it replaces the following sequences of characters and keeps the other ones unchanged Libraries date 499 Sequence Replaced with dd day 2 digits ddd day of week 3 char HH hour 2 digits 01 12 or 00 23 MM minute 2 digits mm month 2 digits mmm month 3 char PM AM or PM QQ quarter Q1 to Q4 SS second 2 digits yy year 2 digits yyyy year 4 digits If the sequence PM is foun
317. ss name is specified The names of methods able to act on objects of a particular class are prefixed with the class name followed with two colons Objects are special structures whose contents are accessible only to its methods Function and operator overloading Methods may have the same name as regular functions When LME has to call a function it first checks the type of the input arguments If one of them is an object the corresponding method is called rather than the function defined for non object arguments A method which has the same name as a function or another method is said to overload it User functions as well as built in ones can be overloaded Operators which have a function name for instance x y can also be written plus x y can also be overloaded Special functions called object constructors have the same name as the class and create new objects They are also methods of the class even if their input arguments are not necessarily objects 40 LyME User Manual 1999 2008 Calerga Sarl Inheritance A class subclass may extend the data and methods of another class base class or parent It is said to inherit from the parent In LME objects from a subclass contain in a special field an object of the parent class the field name has the same name as the parent class If LME does not find a method for an object it tries to find one for its parent great parent etc if any An object can also inherit from several parents
318. stopband between wl and wh relatively to half the sampling frequency With an additional input argument which is the string s ellip gives an analog elliptic filter Frequencies are given in rad s See also ellipap Elliptic analog filter prototype Syntax use filter z p k ellipap n rp rs Libraries filter 463 Description ellipap n rp rs calculates the zeros the poles and the gain of an elliptic analog filter of degree n with a cutoff angular frequency of 1 rad s Ripples have a peak to peak magnitude of rp dB in the passband and of rs dB in the stopband See also Ip2bp Lowpass prototype to bandpass filter conversion Syntax use filter z p k lp2bp z0 pO kO wc ww num den lp2bp num0 denO wc ww Description Lp2bp convert a lowpass analog filter prototype with unit angular fre quency to a bandpass analog filter with the specified center angular frequency w0 and bandwidth ww lp2bp z0 p0 k0 wc ww converts a filter given by its zeros poles and gain lp2bp num0 den0 wc ww converts a filter given by its numerator and denominator coefficients in decreasing powers of s The new filter F s is et ee S2 Ww w 4 ra ro c WwS where Fo s is the filter prototype The filter order is doubled See also Up2lp tp2hp lp2bs Ip2bs Lowpass prototype to bandstop filter conversion 464 LyME User Manual 1999 2008 Calerga Sarl Syntax use fil
319. struct2cell Convert a structure array to a cell array Syntax CA struct2cell SA Description struct2cell SA converts a structure or structure array to a cell array The size of the result is nf size SA where nf is the number of fields Cell CA j i1 i2 of the result contains field SA il i2 f where f is the j th field Example SA CA cell2struct 1 ab 2 cde a b struct2cell SA See also cell2struct structarray Create a structure array Syntax SA structarray fieldnamel Al fieldname2 A2 LME Reference objects 319 Description structarray builds a new structure array Input arguments are used by pairs to create the fields for each pair the first argument is the field name provided as a string and the second one is the field values as a cell array All cell arrays must have the same size the resulting structure array has the same size Example SA structarray a 1 2 3 4 b a 1 3 def true See also cell2struct 3 22 Object Functions class Object creation Syntax object class strct classname object class strct classname parentl str class object Description class strct classname makes an object of the specified class with the data of structure strct Object fields can be accessed only from methods of that class i e functions whose name is classname method
320. t ypast i PreArg is a list of additional input arguments for all functions called during integration they are placed before normal arguments For ex ample if its value is 1 abc the integrated function is called with fun 1 abc t y the output function as outfun 1 abc tn yn and so on Examples Default options odeset AbsTol 1le 6 Events EventTime InitialStep MaxStep MinStep NormControl false OnEvent OutputFcn PreArg Refine RelTol le 3 Stats false 288 LyME User Manual 1999 2008 Calerga Sarl Figure 3 2 Van der Pol equation with Refine set to 1 and 4 Option refine ode45 is typically able to use large time steps to achieve the requested tolerance When plotting the output however interpolating it with straight lines produces visual artifacts This is why ode45 inserts 3 interpolated points for each calculated point based on the fifth order approximation calculated for the integration Refine is 4 by default In the following code curves with and without interpolation are com pared see Fig 3 2 Note that the numbers of evaluations of the func tion being integrated are the same mu 1 fun t y y 2 mux 1 y 1 2 y 2 y 1 1 t y ode45 fun 0 5 2 0 odeset Refine 1 Stats true Number of function evaluations 289 Successful steps 42 Failed steps error too large 6 size y 43 2 ti yi ode45
321. t is an error to execute break outside any loop See also case Conditional execution of statements depending on a number or a string See also switch catch Error recovery See also try LME Reference programming constructs 55 continue Continue loop from beginning Syntax continue Description When a continue statement is executed in the scope of a loop con struct while repeat or for statements following continue are ig nored and a new loop is performed if the loop termination criterion is not fulfilled The loop must be in the same function as continue It is an error to execute continue outside any loop See also define Definition of a constant Syntax define c expr define c expr Description define c expr assign permanently expression expr to c It is equiv alent to function y c y expr Since c does not have any input argument the expression is usually constant A semicolon may follow the definition but it does not have any effect define must be the first element of the line spaces and comments are skipped 56 LyME User Manual 1999 2008 Calerga Sarl Examples define e define g define c define G exp 1 9 81 299792458 6 672659e 11 See also unction for Loop controlled by a variable which takes successively the value of the elements of a vector or a list Syntax for v vect s1 end for v list s1 end Description
322. ta in an array of bytes LME Reference input output 341 Syntax s bwrite data s bwrite data precision Description bwrite data stores the contents of the matrix data into an array of class uint8 The second parameter is the precision whose meaning is the same as for fread Its default value is uint8 Examples bwrite 12345 uint32 1l 1x4 uint8 array 57 48 0 0 bwrite 12345 uint32 b 1x4 uint8 array 0 0 48 57 See also clc Clear the text window or panel Syntax clc clc fd Description clc clear console clears the contents of the command line window or panel clc fd clears the contents of the window or panel associated with file descriptor fd disp Simple display on the standard output 342 LyME User Manual 1999 2008 Calerga Sarl Syntax disp obj Description disp obj displays the object obj Command format may be used to control how numbers are formatted Example disp hello hello See also fclose Close a file Syntax fclose fd fclose all Description fclose fd closes the file descriptor fd which was obtained with functions such as fopen Then fd should not be used anymore fclose all closes all the open file descriptors feof Check end of file status Syntax b feof fd Description feof fd is false if more data can be read from file descriptor fd and true if the end of the file has been reached LME Reference
323. ter z p k lp2bs z0 pO kO wc ww num den lp2bs num0 denO wc ww Description lp2bs convert a lowpass analog filter prototype with unit angular fre quency to a bandstop analog filter with the specified center angular frequency w0 and bandwidth ww lp2bs z0 p0 k0 wc ww converts a filter given by its zeros poles and gain lp2bs num0 den0 wc ww converts a filter given by its numerator and denominator coefficients in decreasing powers of s The new filter F s is F s F te S Fo S w w2 4 where F o s is the filter prototype The filter order is doubled See also Ip2hp Lowpass prototype to highpass filter conversion Syntax use filter z p k lp2hp z0 pO kO w0 num den lp2hp num0 den0 w0 Description lp2hp convert a lowpass analog filter prototype with unit angular fre quency to a highpass analog filter with the specified cutoff angular frequency w0 lp2hp z0 p0 k0 w0 converts a filter given by its ze ros poles and gain lp2hp num0 den0 w0 converts a filter given by its numerator and denominator coefficients in decreasing powers of s The new filter F s is 1 F s Fo _ Wos where Fo s is the filter prototype Libraries lti 465 See also Ip2ip Lowpass prototype to lowpass filter conversion Syntax use filter z p k lp2lp z0 pO kO w0 num den lp2lp num0 den0 w0 Description lp2lp convert a lowpass analog filter proto
324. the states of size n ni to replace the non integrated states or empty to replace no state this can be used to display re sults or to store them in a file for instance Event times are computed after an integration step has been ac cepted If an event occurs before the end of the integration step the step is shortened event information is stored in the output arguments LME Reference non linear numerical functions 287 of odex te ie and ye and the OnEvent function is called The output arguments t and y of odex contain two rows with the same time and the state right before the event and right after it The time step used for integration is not modified by events Additional arguments Past is a logical value which if it is true specifies that the time and state values computed until now what will eventually be the result of ode23 or ode45 are passed as additional input arguments to functions called during intergration This is especially useful for delay differen tial equations DDE where the state at some time point in the past can be interpolated from the integration results accumulated until now with interp1 Assuming no additional parameters or PreArg see be low functions must be defined as function yp f t y tpast ypast function stop outfun tn yn tpast ypast function eventTime eventtimefun t y tpast ypast function value isterminal direction eventsfun t y tpast ypast function yn onevent t y tpas
325. the trailing variables are not defined The function may use the nargin function to know how many arguments were passed by the caller to avoid accessing the undefined variables Note that if you want to have an optional argument before the end of the list you have to interpret the meaning of the variables yourself LME always sets the nargin first arguments There are two other ways to let a function accept a variable num ber of input arguments to define default values directly in the func tion header or to call varargin to collect some or all of the input arguments in a list With one argument nargin fun returns the maximum number of input arguments a function accepts fun may be the name of a built in or user function a function reference or an inline function Func tions with a variable number of input arguments such as fprintf give 1 Examples A function with a default value pi for its second argument 94 LyME User Manual 1999 2008 Calerga Sarl function x multiplyByScalar a k if nargin lt 2 multiplyByScalar x k pi Same as multiplyByScalar x pi end x k gt a A function with a default value standard output for its first argument Note how you have to interpret the arguments function fprintstars fd n if nargin fprintstars n to standard output fprintf repmat 1 fd n is actually stored in fd else fprintf fd repmat 1 n end Number of input arguments of function pl
326. tion series a b connects the outputs of lti object a to the inputs of lti object b series a b outa inb connects outputs outa of a to inputs inb of b Unconnected outputs of a and inputs of b are discarded See also ti mtimes lti paralle Iti repmat Replicate a system Syntax use lti b repmat a n b repmat a m n b repmat a m n Description repmat a n when ais a transfer function or a matrix of transfer func tions creates a new system described by a matrix of transfer functions where a is repeated n times horizontally and vertically If a is a state space system matrices B C and D are replicated to obtain the same effect repmat a m n or repmat a m n repeats matrix a m times ver tically and n times horizontally 482 LyME User Manual 1999 2008 Calerga Sarl See also Iti size Number of outputs and inputs Syntax use lti s size a nout nin size a n size a dim Description With one output argument size a gives the row vector nout nin where nout is the number of outputs of system a and nin its number of inputs With two output arguments size a returns these results separately as scalars size a 1 gives only the number of outputs and size a 2 only the number of inputs See also Uti isempty Lti issiso Iti ssdata Get state space matrices Syntax use lti A B C D ssdata a A B C D Ts ssdata a Description ssdata a
327. tiveca uint8 uint16 uint32 int8 int16 int32 Convert binary data to a vector of integer numbers Syntax vec int8 d vec int16 d vec int32 d vec uint8 d vec uint16 d vec uint32 d Description int8 d int16 d and int32 d convert binary data d to a column vector of signed integer numbers of size 8 16 or 32 respectively uint8 d uint16 d and uint32 d convert binary data d to a col umn vector of unsigned integer numbers of size 8 16 or 32 respec tively Each 16 bit word in the binary data d corresponds to 2 8 bit integers 1 16 bit integer or half a 32 bit integer See also length Number of words in a binary data object Syntax n length d Description Length d gives the number of words in a binary data object See also 406 LyME User Manual 1999 2008 Calerga Sarl pcenativecall Call native ARM machine language in binary data Syntax dataout pcenativecall code data dataout result pcenativecall code datain Description pcenativecall code datain calls native ARM code in binary data code with an argument pointing to datain It returns the same block of memory corresponding to datain possibly modified by the execution of the code This call is available only on handhelds with an ARM micro processor It relies on Palm OS function PceNativeCall The native function should have the following prototype where datain points to the argument of pcenativecall
328. tput arguments X L K care also re turns the gain matrix K defined as K R 1B x and the column vector of closed loop eigenvalues L eig A BK care A S Q true with up to two output arguments is equivalent to care A B Q or care A B Q false with S BxB Example A 4 2 1 2 B 0 1 C 2 1 Q C C R 5 X L K care A B Q R XE 1 07 3 5169 3 5169 23 2415 L 4 3488 2 2995 K _ 0 7034 4 6483 A X Xx A XxB Rx B X Q 1 7319e 14 1 1369e 13 8 5265e 14 6 2528e 13 LME Reference linear algebra 191 See also chol Cholesky decomposition Syntax M2 chol M1 Description If a square matrix M1 is symmetric or hermitian and positive definite it can be decomposed into the following product M M5M2 where M2 is an upper triangular matrix The Cholesky decomposi tion can be seen as a kind of square root The part of M1 below the main diagonal is not used because M1 is assumed to be symmetric or hermitian An error occurs if M1 is not positive definite Example chol 5 3 3 8 Wux ON I I 2361 1 3416 2 4900 co w See also cond Condition number of a matrix Syntax x cond M 192 LyME User Manual 1999 2008 Calerga Sarl Description cond M returns the condition number of matrix M i e the ratio of its largest singular value divided by the smallest one or infinity for singu lar matrices The larger the cond
329. tructure of two fields int integer size ptr pointer size info threads displays the ID of all threads With an output argu ment info threads gives a structure array which describes each thread with the following fields id thread ID totaltime execution time in seconds Only the first character of the argument is meaningful info b is equivalent to info builtin Examples info LME 5 1 info s int 8 bytes ptr 8 bytes info b abs acos acosh etc info v ans 1x1 complex vars info v var 2x1 struct array 2 fields See also inline Creation of inline function Syntax fun inline funstr fun inline expr fun inline expr argl fun inline funstr param fun inline expr argl paramstruct fun inline expr true 88 LyME User Manual 1999 2008 Calerga Sarl Description Inline function are LME objects which can be evaluated to give a result as a function of their input arguments Contrary to functions declared with the function keyword inline functions can be assigned to vari ables passed as arguments and built dynamically Evaluating them with feval is faster than using eval with a string because they are compiled only once to an intermediate code They can also be used as the argument of functions such as fzero and fmin inline funstr returns an inline function whose source code is funstr Input argument funstr follows the same syntax as a plain funct
330. tructures Like lists and cell arrays structures are sets of data of any type While list elements are ordered but unnamed structure elements called fields have a name which is used to access them There are two ways to make structures with the struct function or by setting each field in an assignment s f refers to the value of the field named f in the structure s Usually s is the name of a variable but unless it is in the left part of an assignment it can be any expression which evaluates to a structure a struct name Sysquake os Windows Mac OS X Linux b x 200 b y 280 b radius 90 c s b With the assignments above a os 3 is Linux and c s radius is 90 Structure arrays While structure fields can contain any type of array and cell arrays can have structures stored in their cells structure arrays are arrays where each element has the same named fields Structures are structure arrays of size 1 1 like scalar numbers are arrays of size 1 1 Values are specified first by indices between parenthesis then by field name Braces are invalid to access elements of structure arrays 38 LyME User Manual 1999 2008 Calerga Sarl they can be used to access elements of cell arrays stored in structure array fields Structure arrays are created from cell arrays with functions structarray or cell2struct or by assigning values to fields A structarray name
331. ttitude angles Syntax pitch roll yaw q2rpy q Description q2rpy q gives the pitch roll and yaw angles corresponding to the rotation given by quaternion q It is the inverse of rpy2q All angles are given in radians If the input argument is a quaternion array the results are arrays of the same size conversion from quaternion to angles is performed independently on corresponding elements Quaternions 377 See also rpy2q q2str Conversion from quaternion to string Syntax str q2str q Description q2str q converts quaternion q to its string representation with the same format as disp See also quaternion format qimag Quaternion imaginary parts Syntax b qimag q Description qimag q gives the imaginary parts of quaternion q as a quaternion i e the same quaternion where the real part is set to zero real q gives the real part of quaternion q as a double number Example q quaternion 1 2 3 4 q 1 2i 3j 4k real q 1 qimag q 2i 3j 4k 378 LyME User Manual 1999 2008 Calerga Sarl See also quaternion qinv Quaternion element wise inverse Syntax b qinv q Description qinv q gives the inverse of quaternion q If its input argument is a quaternion array the result is an quaternion array of the same size whose elements are the inverse of the corresponding elements of the input The inverse of a normalized quaternion is its conjugate Example q
332. type with unit angular fre quency to a lowpass analog filter with the specified cutoff angular frequency w0 Lp2lp z0 p0 k0 w0 converts a filter given by its ze ros poles and gain Lp2lp num0 den w0 converts a filter given by its numerator and denominator coefficients in decreasing powers of s The new filter F s is S F s Fo gt Wo where Fo s is the filter prototype See also Up2hp lp2bp lp2bs 4 7 Iti Library lti defines methods related to objects which represent linear time invariant dynamical systems LTI systems may be used to model many different systems electro mechanical devices robots chemical processes filters etc LTI systems map one or more inputs u to one or more outputs y The mapping is defined as a state space model or as a matrix of transfer functions either in continuous time or in discrete time Methods are provided to create combine and analyze LTI objects Graphical methods are based on the corresponding graphical func tions the numerator and denominator coefficient vectors or the state space matrices are replaced with an LTI object They accept the same optional arguments such as a character string for the style 466 LyME User Manual 1999 2008 Calerga Sarl The following statement makes available functions defined in lti use lti Ss SS LTI state space constructor Syntax Uti v wv v wW wn tou i i i i wn wn u a a a a a a Description ss A B C D
333. ual 1999 2008 Calerga Sarl 0 3370 0 1013 0 1596 0 9393 0 2687 0 4238 D 2903 9354 0 0000 0 0000 0 0000 2867 4882 0 0000 0 0000 0 0000 3173 2074 See also inmem List of functions loaded in memory Syntax inmem SA inmem Description inmem displays the list of user defined functions loaded in memory with the library where they are defined With an output argument inmem gives the result as a structure array which describes each user defined function loaded in memory with the following fields library library name class class name for functions name function name See also isglobal Test for the existence of a global variable Syntax b isglobal str LME Reference miscellaneous functions 91 Description isglobal str returns true if the string str is the name of a global variable defined as such in the current context See also iskeyword Test for a keyword name Syntax b iskeyword str list iskeyword Description iskeyword str returns true if the string str is a reserved keyword which cannot be used as a function or variable name or false other wise Keywords include if and global but not the name of built in functions like sin or i Without input argument iskeyword gives the list of all keywords Examples iskeyword otherwise true iskeyword break case catch continue else elseif end endfunction for
334. ubsref Extraction of a part of an LTI system 484 LyME User Manual 1999 2008 Calerga Sarl Syntax use lti var i j var ix var select var field b subsref a s Description The method subsref a permits the use of all kinds of extraction of a part of an LTI system If the variable is a matrix of transfer func tions subsref produces the expected result If the variable is a state space model the result is equivalent the result remains a state space model For state space models extracting all the inputs or all the outputs with the syntax var expr or var expr is much more efficient than specifying both subscripts or a single index The syntax for field access var field is defined for the following fields for state space models A B C and D matrices of the state space model for transfer functions num and den cell arrays of co efficients for both var string and Ts scalar or empty array for continuous time systems The syntax with braces var i is not supported See also t1 subsasgn joperator subsasgn Iti tfdata Get transfer functions Syntax use lti num den tfdata a num den Ts ssdata a Description tfdata a where a is any kind of LTI object gives the numerator and denominator of the transfer function model and optionally the sampling period or the empty array for continuous time systems Libraries lti 485 The numerators and denominators are g
335. uint8 reads bytes and stores them in an array of class uint8 int32 b reads signed 32 bit words and stores them in an array of class int32 after performing byte swapping if necessary and char reads bytes and stores them in a character row vector i e a plain string 348 LyME User Manual 1999 2008 Calerga Sarl See also fscanf Reading of formatted numbers Syntax r fscanf fd format r count fscanf fd format Description A single line is read from a text file and numbers characters and strings are decoded according to the format string The format string follows the same rules as sscanfl The optional second output argument is set to the number of ele ments decoded successfully may be different than the length of the first argument if decoding strings Example Read a number from a file fopen and fclose are not available in all LME applications fd fopen test txt rt fscanf fd f 2 3 fclose fd See also sscanf fseek Change the current read or write position in a file Syntax status fseek fd position status fseek fd position mode LME Reference input output 349 Description fseek fd position mode changes the position in an open file where the next input output commands will read or write data The first ar gument fd is the file descriptor returned by fopen or similar functions fopen is not available in all LME applications The se
336. ult value The result is a structure whose fields correspond to each option Without any input argument odeset creates a structure with all the default options Note that ode23 and ode45 also interpret the lack of an option argument or the empty array as a request to use the default values When its first input argument is a structure odeset adds or changes fields which correspond to the name value pairs which follow Here is the list of permissible options empty arrays mean auto matic Name Default Meaning AbsTol le 6 maximum absolute error Events none state based event function EventTime none time based event function InitialStep 10 MinStep initial time step MaxStep time range 10 maximum time step MinStep time range le6 minimum time step NormControl false error control on state norm OnEvent none event function OutputFcn none output function Past false provide past times and states PreArg list of prepended input arguments Refine 1 4 for ode45 refinement factor RelTol le 3 maximum relative error Stats false statistics display LME Reference non linear numerical functions 285 Time steps and output Several options control how the time step is tuned during the numeri cal integration Error is calculated separately on each element of y if NormControl is false or on norm y if it is true time steps are chosen so that it remains under AbsTol or RelTol times the state which
337. ultiplication of polynomials corresponds to convolution no need to understand what it means here of the coefficient vectors gt conv 1 2 2 4 5 ans 2 8 13 10 Hence x 2 2x 4x 5 2x34 8x 13x 10 22 LyME User Manual 1999 2008 Calerga Sarl 2 5 Strings You type strings by bracketing them with single quotes gt Hello World ans Hello World If you want single quotes in a string double them gt Easy isn t it ans Easy isn t it Some control characters have a special representation For example the line feed used in LME as an end of line character is n gt Hello nWorld ans Hello World Strings are actually matrices of characters You can use commas and semicolons to build larger strings gt a bc de f ans abc def 2 6 Variables You can store the result of an expression into what is called a variable You can have as many variables as you want and the memory permits Each variable has a name to retrieve the value it contains You can change the value of a variable as often as you want gt a s 3s gt a 5 ans 8 gt a 4 gt a 5 ans 9 Note that a command terminated by a semicolon does not display its result To see the result remove the semicolon or use a comma if you have several commands on the same line Implicit assignment to variable ans is not performed when you assign to another variable or when you
338. umber x such that x gt 1 Syntax e e e eps eps x eps type Description Because of the floating point encoding of real numbers the absolute precision depends on the magnitude of the numbers The relative precision is characterized by the number given by eps which is the smallest double positive number such that 1 eps can be distinguished from 1 eps x gives the smallest number e such that x e has the same sign as x and can be distinguished from x It takes into account LME Reference mathematical functions 155 whether x is a double or a single number If x is an array the re sult has the same size each element corresponds to an element of the input eps single gives the smallest single positive number e such that 1single e can be distinguished from lsingle eps double gives the same value as eps without input argument Examples eps 2 2204e 16 1 eps 1 2 2204e 16 eps 2 1 1102e 16 1 eps 2 1 0 See also erf Error function Syntax y erf x Description erf x gives the error function of x Argument and result are real imaginary part is discarded The error function is defined as 2 x t2 ert e dt 0 Example erf 1 0 8427 See also 156 LyME User Manual 1999 2008 Calerga Sarl erfc Complementary error function Syntax y erfc x Description erfc x gives the complementary error function of x Argument and result are real imaginary part i
339. unctions are public by default Example Here is a library for computing the roots of a second order polynomial Only function roots2 may be called from the outside of the library private function d discr a b c d b2 4x ax Cc public function r roots2 p a p 1 b p 2 c p 3 d discr a b c s b sqrt d b sqrt d 2 a See also LME Reference programming constructs 63 public Mark the beginning of a sequence of public function definitions in a library Syntax public Description In a library functions which are defined after the public keyword are public public may not be placed in the same line of source code as any other command comments are possible though In a library functions are either public or private Private functions can only be called from the same library while public functions can also be called from contexts where the library has been imported with a use command Functions are public by default the public keyword is not required at the beginning of the library See also private function repeat Loop controlled by a boolean expression Syntax repeat sl until expr Description The statements between the repeat statement and the corresponding until are executed repeatedly at least once until the expression of the until statement yields true nonempty and all elements different from 0 and false 64 LyME User Manual 1999 2008 Caler
340. unsigned 8 bit integers They differ from the uint8 type when they are used to select the elements of an array or list Examples a 1 3 a 1 0 1 Index out of range a 1 3 a logical 1 0 1 1 3 332 LyME User Manual 1999 2008 Calerga Sarl See also true Boolean constant true Syntax b true B true n B true nl1 n2 B true nl1 n2 Description The boolean constant true can be used to set the value of a variable It is equivalent to Logical 1 The constant 1 is equivalent in many cases indices to getjor set the elements of an array are an important exception With input arguments true builds a logical array whose elements are true The size of the array is specified by one integer for a square matrix or several integers either as separate arguments or in a vec tor for an array of any size Examples true true islogical true true true 2 TT TT See also logical jones xor Exclusive or LME Reference dynamical systems 333 Syntax b3 xor b1 b2 Description xor b1 b2 performs the exclusive or operation between the corre sponding elements of b1 and b2 b1 and b2 must have the same size or one of them must be a scalar Examples xor false false true true false true false true FTTFE xor pi 8 false See also 3 24 Dynamical System Functions This section describes functions related to linear time invariant dy namical systems c2dm Co
341. ure imaginary nonzero numbers as I and zeros as spaces The default format is format short g format j and format compact See also disp fprintf 346 LyME User Manual 1999 2008 Calerga Sarl fprintf Formatted output Syntax fprintf fd format a b fprintf format a b Description fprintf format a b converts its arguments to a string and writes it to the standard output fprintf fd format a b spec ifies the output file descriptor See sprintf for a description of the conversion process Example fprintf d 2f 3E g n 1 3 pi d 1 2 00 3 000E0 3 1416 22 Caveat Same limitations as sprintf See also fread Raw input Syntax a count fread fd a count fread fd size a count fread fd size precision LME Reference input output 347 Description fread fd reads signed bytes from the file descriptor fd until it reaches the end of file It returns a column vector whose elements are signed bytes between 128 and 127 and optionally in the second output argument the number of bytes it has read fread fd size reads the number of bytes specified by size If size is a scalar that many bytes are read and result in a column vector If size is a vector of two elements m n mxn elements are read row by row and stored in an m by n matrix If the end of the file is reached before the specified number of elements have been read the number of rows is reduced without
342. us usually written nargin plus 2 See also nargout varargin function nargout Number of output arguments Syntax n n nargout nargout fun Description A function may be called with between 0 and the number of out put arguments listed in the function definition The function can use nargout to check whether some output arguments are not used so that it can avoid computing them or do something else With one argument nargout fun returns the maximum number of output arguments a function can provide fun may be the name of a built in or user function a function reference or an inline function Functions with a variable number of output arguments such as feval give 1 LME Reference miscellaneous functions 95 Example A function which prints nicely its result when it is not assigned or used in an expression function y multiplyByTwo x if nargout gt 0 y 2 X else fprintf The double of f is f n x 2 x end Maximum number of output arguments of svd nargout svd 3 See also nargin varargout function rethrow Throw an error described by a structure Syntax rethrow s Description rethrow s throws an error described by structure s which contains the same fields as the output of Lasterror rethrow is typically used in the catch part of a try catch construct to propagate further an error but it can also be used to initiate an error like err
343. v1 sorts its elements and removes duplicate elements Unless v1 is a row vector v1 is considered as a column vector With an argument which is a list of strings unique list sorts its elements and removes duplicate elements The optional second output argument is set to a vector of indices such that if b ia unique a then b is a ia The optional third output argument is set to a vector of indices such that if b ia ib unique a then ais b ib Examples b ia ib unique 4 7 3 8 7 1 3 b 13478 ia 63124 ib 3425412 unique def ab def abc ab abc def See also zeros Null array LME Reference triangulation 267 Syntax A zeros n A zeros nl1 n2 A zeros nl1 n2 A zeros type Description zeros builds an array whose elements are 0 The size of the array is specified by one integer for a square matrix or several integers either as separate arguments or in a vector for an array of any size An additional input argument can be used to specify the type of the result It must be the string double single int8 int16 int32 int64 uint8 uint16 uint32 or uint64 64 bit arrays are not supported on all platforms Examples zeros 2 3 000 000 zeros 2 0 0 0 0 zeros 1 5 uint16 1x5 uint16 array 0000 0 See also 3 16 Triangulation Functions delaunay
344. v2 must be row or columns vectors of three components or arrays of LME Reference linear algebra 195 the same size containing several such vectors When there is ambi guity a third argument dim may be used to specify the dimension of vectors 1 for column vectors 2 for row vectors and so on Examples cross 1 2 3 0 0 1 2 1 0 cross 1 2 3 7 1 3 4 0 0 0 2 0 2 0 12 8 6 0 14 See also cumprod Cumulative products Syntax M2 cumprod M1 M2 cumprod M1 dim Description cumprod M1 returns a matrix M2 of the same size as M1 whose ele ments M2 i j are the product of all the elements M1 k j with k lt i cumprod M1 dim operates along the dimension dim column wise if dim is 1 row wise if dim is 2 Examples cumprod 1 2 3 4 5 6 1 2 3 4 10 18 cumprod 1 2 3 4 5 6 2 12 6 4 20 120 See also prod cumsum 196 LyME User Manual 1999 2008 Calerga Sarl cumsum Cumulative sums Syntax M2 cumsum M1 M2 cumsum M1 dim Description cumsum M1 returns a matrix M2 of the same size as M1 whose ele ments M2 i j are the sum of all the elements M1 k j with k lt i cumsum M1 dim operates along the dimension dim column wise if dim is 1 row wise if dim is 2 Examples cumsum 1 2 3 4 5 6 12 3 579 cumsum 1 2 3 4 5 6 2 13 6 49 15 See also dare Discrete time algebraic Riccati equation Syntax X L K dare A B Q X L K dare A
345. values Syntax use stat m harmmean A m Description harmmean A dim harmmean A gives the harmonic mean of the columns of array A or of the row vector A The dimension along which harmmean proceeds may be specified with a second argument The inverse of the harmonic mean is the arithmetic mean of the inverse of the observations Example use stat harmmean 1 10 3 4142 mean 1 10 5 5 See also geomean iqr Interquartile range Syntax use stat m igr A m igr A dim Libraries stat 429 Description iqr A gives the interquartile range of the columns of array A or of the row vector A The dimension along which igr proceeds may be specified with a second argument The interquartile range is the difference between the 75th per centile and the 25th percentile Example use stat igqr rand 1 1000 0 5158 See also mad Mean absolute deviation Syntax use stat m mad A m mad A dim Description mad A gives the mean absolute deviation of the columns of array A or of the row vector A The dimension along which mad proceeds may be specified with a second argument The mean absolute deviation is the mean of the absolute value of the deviation between each observation and the arithmetic mean Example use stat mad rand 1 1000 0 2446 See also 430 LyME User Manual 1999 2008 Calerga Sarl nancorrcoef Correlation coefficients after discarding NaNs Syntax use
346. ve Example abs 2 3 0 3 4j 2305 See also acos Arc cosine Syntax y acos x Description acos x gives the arc cosine of x which is complex if x is complex or if abs x gt 1 Examples acos 2 0 1 3170j acos 0 1 2j 1 5708 1 1437 1 5286j See also acosh Inverse hyperbolic cosine LME Reference mathematical functions 137 Syntax y acosh x Description acosh x gives the inverse hyperbolic cosine of x which is complex if x is complex or if x lt 1 Examples acosh 2 1 3170 acosh 0 1 2j 0 1 5708j 1 5286 1 1437j See also acos acot Inverse cotangent Syntax y acot x Description acot x gives the inverse cotangent of x which is complex if x is See also acoth Inverse hyperbolic cotangent Syntax y acoth x 138 LyME User Manual 1999 2008 Calerga Sarl Description acoth x gives the inverse hyperbolic cotangent of x which is complex if x is complex or is in the range 1 1 See also coth acot atanh acsc Inverse cosecant Syntax y acsc x Description acsc x gives the inverse cosecant of x which is complex if x is com plex or is in the range 1 1 See also acsch Inverse hyperbolic cosecant Syntax y acsch x Description acsch x gives the inverse hyperbolic cosecant of x which is complex if x is See also LME Reference mathematical functions 139 angle Phase angle of a complex number
347. which are far away from the points clf scale equal 0 1 0 1 plot x y x Voronoi polygons are displayed in a loop skipping unbounded poly gons The first vertex is repeated to have closed polygons Since plot expects row vectors vertex coordinates are transposed for pl p if any p1 1 pl pl p1 1 plot v p1 1 v p1 2 end end See also vorono1n jde Launay voronoin N d Voronoi tessalation Syntax v p voronoin x Description voronoin x calculates the Voronoi tessalation of the set of points given by the rows of arrays x in a space of dimension n size x 2 The first output argument v is an array of n columns which contains the coordinates of the vertices of the Voronoi cells one row per vertex The first row contains infinity and is used as a marker for unbounded Voronoi cells The second output argument p is a list of vectors of row indices in v each element describes the Voronoi cell corresponding to a point in x In each cell vertices are sorted by index 274 LyME User Manual 1999 2008 Calerga Sarl See also 3 17 Integer Functions uint8 uint16 uint32 uint64 int8 int16 int32 int64 Conversion to integer types Syntax uint8 A uint16 A vvv Description The functions convert a number or an array to unsigned or signed integers The name contains the size of the integer in bits To avoid a conversion from double to integer constant
348. wo operands both operands are added together If both operands are matrices with a size different from 1 by 1 their size must be equal the addition is performed element wise If one operand is a scalar it is added to each element of the other operand With one operand no operation is performed except that the result is converted to a number if it was a string or a logical value like with all mathematical operators and functions For strings each character is replaced with its numerical encoding The prefix is actually a synonym of double plus x y is equivalent to x y and uplus x to x They can be used to redefine these operators for objects Example 2 3 5 1 2 3 5 47 3 4 2 56 See also Operator Subtraction or negation Syntax xX y M1 M2 M x minus x y 114 LyME User Manual 1999 2008 Calerga Sarl X M uminus x Description With two operands the second operand is subtracted from the first operand If both operands are matrices with a size different from 1 by 1 their size must be equal the subtraction is performed element wise If one operand is a scalar it is repeated to match the size of the other operand With one operand the sign of each element is changed minus x y is equivalent to x y and uminus x to x They can be used to redefine these operators for objects Example 2 3 1 1 2 3 5 2 3 3 4 2 12 2 2 3j 2 24 3j See also oper
349. x is 1 if x gt 0 0 if x 0 or 1 if x lt 0 With a complex argument sign z1 is a complex value with the same phase as z1 and whose magnitude is 1 Examples Sign 2 1 sign 1 1j 0 7071 0 7071j sign 0 5 01 See also sec Secant Syntax y sec x Description sec x gives the secant of x which is complex if x is See also LME Reference mathematical functions 183 sech Hyperbolic secant Syntax y sech x Description acot x gives the hyperbolic secant of x which is complex if x is See also asech sec cosh sin Sine Syntax y sin x Description sin x gives the sine of x which is complex if x is complex Example sin 2 0 9093 See also sinc Sinc Syntax y sinc x 184 LyME User Manual 1999 2008 Calerga Sarl Description sinc x gives the sinc of x i e sin pi x pi x if x 0 or 1 if x 0 The result is complex if x is complex Example sinc 1 5 0 2122 See also single Conversion to single precision numbers Syntax B single A Description single A converts number or array A to single precision A can be any kind of numeric value real complex or integer or a character or logical array Single literal numbers can be entered as a floating point number with the single suffix Examples single pi 3 1416single Single AB 1x2 single array 65 66 3 7e4single 37000single See also and related
350. y for the task Stack overflow Too complex expression or too many nested func tion calls Data stack overflow Too large objects on the stack in expres sions or in nested function calls Variable overflow Not enough space to store the contents of a variable Code overflow Not enough memory for compiling the program Not enough memory Not enough memory for an operation out side the LME core 42 LyME User Manual 1999 2008 Calerga Sarl Algorithm does not converge A numerical algorithm does not converge to a solution or does not converge quickly enough This usually means that the input arguments have invalid values or are ill conditioned Incompatible size Size of the arguments of an operator or a func tion do not agree together Bad size Size of the arguments of a function are invalid Non vector array A row or column vector was expected but a more general array was found Not a column vector A column vector was expected but a more general array was found Not a row vector A row vector was expected but a more general array was found Non matrix array A matrix was expected but an array with more than 2 dimensions was found Non square matrix A square matrix was expected but a rectan gular matrix was found Index out of range Index negative or larger than the size of the array Wrong type String or complex array instead of real etc Non integer argument An argument has a fractional part while a
351. yntax X V V sum v sum M sum M dim Description sum v returns the sum of the elements of vector v sum M returns a row vector whose elements are the sums of the corresponding columns of matrix M sum M dim returns the sum of matrix M along dimension dim the result is a row vector if dim is 1 or a column vector if dim is 2 Examples sum 1 5 15 sum 1 5 15 sum 1 2 3 5 6 7 6 8 10 sum 1 2 3 5 6 7 1 6 8 10 sum 1 2 3 5 6 7 2 6 18 See also prod LME Reference linear algebra 231 svd Singular value decomposition Syntax s svd M U S V svd M U S V svd M false Description The singular value decomposition U S V svd M decomposes the m by n matrix M such that M UxS V where S is an m by n diagonal matrix with decreasing positive diagonal elements the singular values of M Uis an m by m unitary matrix and V is an n by n unitary matrix The number of non zero diagonal elements of S up to rounding errors gives the rank of M When M is rectangular in expression U S V some columns of U or V are multiplied by rows or columns of zeros in S respectively U S V svd M false produces U S and V where these columns or rows are discarded relationship M U S V still holds Size of A Size of U Size ofS Size of V mbyn m lt n mbym m by m n by m mbyn m gt n m by n n by n n by n svd M true produces the same result as svd M With one output argument s sv
352. yntaxes fun fun fun inl1 fun inl in2 outl fun out1 out2 fun out1 out2 fun out1 out2 fun Input arguments are enclosed between parenthesis They are passed to the called function by value which means that they cannot be mod ified by the called function When a function is called without any input argument parenthesis may be omitted Output arguments are assigned to variables or part of variables structure field list element or array element A single output argu ment is specified on the left on an equal character Several output arguments must be enclosed between parenthesis or square brackets arguments can simply be separated by spaces when they are en closed in brackets Parenthesis and square brackets are equivalent as far as LME is concerned parenthesis are preferred in LME code but square brackets are available for compatibility with third party appli cations In some cases a simpler syntax can be used when the function has only literal character strings as input arguments The following conditions must be satisfied No output argument Each input argument must be a literal string without any space tabulator comma or semicolon beginning with a letter a digit or one of minus slash dot colon or star containing at least one letter or digit In that case the following syntax is accepted left and right columns are equivalent
353. ze sread ss2tf 338 sscanf 354 std 229 str2fun 96 str2obj string strmatch strtok strtrim 305 struct struct2cell structarray 318 structure 37 structure array 37 sub2ind 262 subsasgn 51 subspace 424 subsref sum 230 svd 231 swapbytes switch 65 swrite 355 tan 186 tanh 187 text tf2ss tic B69 times 105 toc toeplitz trace transpose 105 trapz tri BS trimmean 436 LyME User Manual 1999 2008 Calerga Sarl triu 264 true 332 try 66 tsearch 270 tsearchn 271 typecast 187 uint16 274 405 uint32 274 405 uint 4 274 uint8 274 405 ulawcompress 495 ulawexpand uminus 105 union 265 unique until uplus upper 306 use useifexists 68 ut f8decode utf8encode value sequences 38 var 232 varargin 97 varargout OR yale ER vertcat fede lete DESI vfsdir 365 vfsgetvolumes 366 vfsmkdir 367 vfsopen 36 vfsrename voronoi 27 voronoin wa rood ee wavread 496 wavwrite 497 weekday which while 68 xor B32 68 NI QU Index 511 zeros 266 zscore 436
Download Pdf Manuals
Related Search
Related Contents
Scarica l`allegato ABNEY STEAM SHOWER ENCLOSURE Operation Manual-Spare Parts FRANCA 2014 Brother 2400 Printer User Manual マスク -製品マニュアル S卿隅 ズーム機能付き拡大鏡 取扱説明書 Sony MHC-GX90D System User`s Manual Template - Stand Up Professional Copyright © All rights reserved.
Failed to retrieve file