Previous Page Next Page Contents

text2expr -- convert a character string to an expression

Introduction

text2expr(text) interprets the character string text as MuPAD input and generates the corresponding object.

Call(s)

text2expr(text)

Parameters

text - a character string

Returns

a MuPAD object.

Related Functions

coerce, expr2text, input, int2text, tbl2text, text2int, text2list, text2tbl

Details

Example 1

A character string is converted to a simple expression. The newly created expression is not evaluated automatically:

>> text2expr("21 + 21")
                                  21 + 21

It may be evaluated via eval:

>> eval(%)
                                    42

Example 2

A character string is converted to a statement sequence:

>> text2expr("x:= 3; x + 2 + 1"); eval(%)
                                (x := 3;
                                x + 2 + 1)
      
                                     6
>> x
                                     3
>> delete x:

Example 3

A matrix is converted to a string:

>> matrix([[a11, a12], [a21, a22]])
                              +-          -+
                              |  a11, a12  |
                              |            |
                              |  a21, a22  |
                              +-          -+
>> expr2text(%)
      "Dom::Matrix()(array(1..2, 1..2, (1,1) = a11, (1,2) = a12, (2,\
      1) = a21, (2,2) = a22))"

The string is reconverted to a matrix:

>> text2expr(%)
      Dom::Matrix()(array(1..2, 1..2, (1, 1) = a11, (1, 2) = a12,
      
         (2, 1) = a21, (2, 2) = a22))
>> eval(%)
                              +-          -+
                              |  a11, a12  |
                              |            |
                              |  a21, a22  |
                              +-          -+

Changes




Do you have questions or comments?


Copyright © SciFace Software GmbH & Co. KG 2000