[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: sprintf help
From: |
John W. Eaton |
Subject: |
Re: sprintf help |
Date: |
Fri, 15 May 2015 11:19:43 -0400 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Icedove/31.2.0 |
On 05/15/2015 12:53 AM, rik wrote:
> Could someone run the following code under Matlab?
>
> -- Begin Code --
> x = sprintf ('%s%s%s\n', [65 66 67])
> size (x)
>
> y = sprintf ('%s %s%s\n', [65 66 67])
> size (y)
> -- End Code --
>
> Octave returns 1x3, i.e., missing the newline character. Unless there is
> something after the first '%s' in the format specification such as a
space.
The [65, 66, 67] matrix is a single argument and is converted to a
string for printing here and the %s converts the entire string. When
you add the space, Y should contain "ABC ". Since there are no further
arguments to convert after the first, the rest of the format is skipped.
Isn't that the correct behavior?
jwe