sci2exp
returns a string able to generate a given Scilab object
Syntax
t = sci2exp(a) t = sci2exp(a, LHSname) t = sci2exp(a, LHSname, lmax) t = sci2exp(a, lmax)
Arguments
- a
a scilab object. The supported types are:
- booleans
- encoded integers of any inttype
- real or complex numbers
- sparse matrices
- polynomials
- strings, that may include some NewLine (ascii(10)) sequences
- a structures array or cells array with any number of dimensions
- a simple list whose components types are supported by
sci2exp
- a typed list tlist() and mlist()
- a single graphic handle (only of figure or uicontrol).
For booleans, encoded integers, real or complex numbers, polynomials and strings, any of a single element or a vector or a matrix or an hypermatrix is accepted.
- LHSname
Optional string: The name of the variable building the assignment prefix
LHSname+" = "
. When it is provided,LHSname+" = "
is prepended to the raw expression yielded from thea
object. Then, the result stringt
can no longer be evaluated withevstr()
but withexecstr()
.- t
Column of strings. A single whole string is returned when
lmax
is not used or is set to 0: The Scilab literal expression, with possibly the left-hand affectation part on the first line whenLHSname
is provided.- lmax
Positive integer setting the maximal length of the
t
components. The default value0
ignores such a constrain and returnst
as a single (long) string. Otherwise, some continuation marks..
are used to break too long rows.Since continuation marks..
prevent usingevstr()
andexecstr()
, using thislmax
option mostly cancels the mainsci2exp()
purpose.
Description
"sci2exp" stands for the conversion of a scilab object into a literal executable expression.
|
Examples
With a numerical matrix:
a = [%i 2 ; 3 4-2*%i] sci2exp(a) sci2exp(a, 'aa') sci2exp(a, 'aa', 10)
--> a = [%i 2 ; 3 4-2*%i] a = i 2. 3. 4. - 2.i --> sci2exp(a) ans = [%i,2;3,4-%i*2] --> sci2exp(a, 'aa') ans = aa = [%i,2;3,4-%i*2] --> sci2exp(a, 'aa', 10) ans = !aa = [ ! !%i,2; ! !3,4-%i*2] !
With some other types of objects:
sci2exp(ssrand(2,2,2)) // a typed list created with tlist() sci2exp(figure("figure_name","figure1")) // a graphic handle
Impact of format() on literal output numbers:
p = [0.123456789, %z-%pi*%i]; pol2str(p) // also impacted by format() format(20); Lp = sci2exp(p) // Literal encoding Rp = evstr(Lp); pol2str(Rp) // Regenerated from literal Rp == p format(10); // Let's truncate the literal output before calling sci2exp() Lp = sci2exp(p) Rp = evstr(Lp); format(20); pol2str(Rp) Rp == p
--> p = [0.123456789, %z-%pi*%i]; --> pol2str(p) ans = !0.1234568 -%i*3.1415927+z ! --> format(20) --> Lp = sci2exp(p) Lp = [0.12345678900000000,-%i*3.14159265358979310+%z] --> Rp = evstr(Lp); pol2str(Rp) ans = !0.12345678900000000 -%i*3.14159265358979310+z ! --> Rp == p ans = T T --> format(10) // Let's truncate the literal output before calling sci2exp() --> Lp = sci2exp(p) Lp = [0.1234568,-%i*3.1415927+%z] --> Rp = evstr(Lp); format(20); pol2str(Rp) ans = !0.12345680000000001 -%i*3.14159269999999990+z ! --> Rp == p ans = F F
See also
- string — преобразование в строку
- prettyprint — Converts a Scilab object into some corresponding LaTeX, TeX, MathML or HTML strings
- format — установка выходного формата десятичных чисел по умолчанию
- pol2str — polynomial to string conversion
- evstr — вычисление выражений
- execstr — execute Scilab code in strings
History
Версия | Описание |
6.0.2 | The name of the predefined variables %s and
%z is now used as literal generator for input polynomials in
s or z . |
2024.1.0 | sci2exp(c) , where c is a cell, now returns expression using {} instead of makecell . |
Report an issue | ||
<< regexp | Строки | strcat >> |