octave-bug-tracker
[Top][All Lists]
Advanced

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

[Octave-bug-tracker] [bug #42235] "invalid conversion from string to rea


From: Pantxo Diribarne
Subject: [Octave-bug-tracker] [bug #42235] "invalid conversion from string to real scalar" with %c
Date: Tue, 17 Jun 2014 18:12:04 +0000
User-agent: Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:29.0) Gecko/20100101 Firefox/29.0

Follow-up Comment #4, bug #42235 (project octave):

The following example in matlab shows that "%s" and "%c" are different:

>> sprintf ('%4c', 'abcd') % note the 3 white spaces before each character
ans =
   a   b   c   d
>> sprintf ('%4s', 'abcd')
ans =
abcd
>> sprintf ('%c,%c,%c,%c', 'abcd')
ans =
a,b,c,d
>> sprintf ('%s,%s,%s,%s', 'abcd')
ans =
abcd,


The string 'abcd' is an array of characters. In Mike's test, all the
characters are treated one after the other using the same format specifier.
This behavior is true for all format specifiers except %s which is meant to
handle multiple characters at the same time [1].

[1] http://www.mathworks.fr/fr/help/matlab/ref/sscanf.html

    _______________________________________________________

Reply to this item at:

  <http://savannah.gnu.org/bugs/?42235>

_______________________________________________
  Message sent via/by Savannah
  http://savannah.gnu.org/




reply via email to

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