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
sci2expa 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 theaobject. Then, the result stringtcan no longer be evaluated withevstr()but withexecstr().- t
Column of strings. A single whole string is returned when
lmaxis not used or is set to 0: The Scilab literal expression, with possibly the left-hand affectation part on the first line whenLHSnameis provided.- lmax
Positive integer setting the maximal length of the
tcomponents. The default value0ignores such a constrain and returnstas a single (long) string. Otherwise, some continuation marks..are used to break too long rows.
Since continuation marks
..prevent usingevstr()andexecstr(), using thislmaxoption 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
History
| バージョン | 記述 |
| 6.0.2 | The name of the predefined variables |
| 2024.1.0 |
|
| Report an issue | ||
| << regexp | Strings | strcat >> |
