help-octave
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Octave/Matlab compatibility


From: John W. Eaton
Subject: Re: Octave/Matlab compatibility
Date: Mon, 24 Nov 1997 13:11:28 -0600

On 24-Nov-1997, Heber Farnsworth <address@hidden> wrote:

| I agree.  Returning a numeric result is the exception.  It is much
| more common (in my work) that I want to be able to enter a string
| and concatenate strings and get another string.

I believe that concatenating two strings works fine.  It's just a
question of what happens when someone mixes strings and numbers
(apparently most often by growing a string starting with an empty
matrix).

In any case, this is fixed for the next release.

  * The new built-in variable `implicit_num_to_str_ok' controls
    whether Octave converts expressions like `[97, 98, 99, "123"]' to
    strings.  The default value is 0 unless you use --traditional.


  octave:1> implicit_str_to_num_ok = 0;, implicit_num_to_str_ok = 0;
  octave:2> [97, 98, 99, '123']
  error: invalid conversion from string to real matrix
  error: invalid conversion from string to real matrix

  octave:2> implicit_str_to_num_ok = 0; implicit_num_to_str_ok = 1;
  octave:3> [97, 98, 99, '123']
  ans = abc123

  octave:4> implicit_str_to_num_ok = 1; implicit_num_to_str_ok = 0;
  octave:5> [97, 98, 99, '123']
  ans =

    97  98  99  49  50  51

  octave:6> implicit_str_to_num_ok = 1; implicit_num_to_str_ok = 1;
  octave:7> [97, 98, 99, '123']
  ans = abc123

The defaults for these variables are both 0 unless you use
--traditional.  Then the defaults are both 1. 

jwe



reply via email to

[Prev in Thread] Current Thread [Next in Thread]