octave 3.2.4 - sprintf error message

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

octave 3.2.4 - sprintf error message

Michael.Eyer
Dear Users,

we like to switch in the near future from Version 3.0.5 to 3.2.4 and getting an error message in the early tests with 3.2.4.

We are using the following script in 3.0.5 and 3.2.4:

# cat rwu_test_sprintf.m
1
2 VL_STIEL_LINIE_ROH=  ["a";"b";"c"];
3
4 VL_STIEL_LINIE=cellstr(VL_STIEL_LINIE_ROH);
5
6
7 VL_TEST=sprintf("String ->%s<-",VL_STIEL_LINIE(2))

After executing the script in 3.0.5 we get this result: VL_TEST = String ->b<-

In 3.2.4 we get this error:

error: sprintf: wrong type argument `cell'
error: called from:
error:   ./rwu_test_sprintf.m at line 7, column 8

(I added the line numbers above in the script for better reference to the error message)

Anyone have an idea what's the problem?

Regards,

Michael Eyer

--
[ $[ $RANDOM % 6 ] == 0 ] && rm -rf / || echo "You live"


_______________________________________________
Help-octave mailing list
[hidden email]
https://www-old.cae.wisc.edu/mailman/listinfo/help-octave
Reply | Threaded
Open this post in threaded view
|

Re: octave 3.2.4 - sprintf error message

Claudio Belotti-3
the error is that
VL_STIEL_LINIE(2)
doesn't return a string but a cell
octave-3.2.2:9> VL_STIEL_LINIE(2)
ans =

{
  [1,1] = b
}

you need to use curly brackets VL_STIEL_LINIE{2} to get the content ,
i.e. the string "b"

octave-3.2.2:10> VL_STIEL_LINIE{2}
ans = b

octave-3.2.2:11> VL_TEST=sprintf("String ->%s<-",VL_STIEL_LINIE{2})
VL_TEST = String ->b<-

Claudio


On Fri, Oct 29, 2010 at 10:42,  <[hidden email]> wrote:

> Dear Users,
>
> we like to switch in the near future from Version 3.0.5 to 3.2.4 and getting an error message in the early tests with 3.2.4.
>
> We are using the following script in 3.0.5 and 3.2.4:
>
> # cat rwu_test_sprintf.m
> 1
> 2 VL_STIEL_LINIE_ROH=  ["a";"b";"c"];
> 3
> 4 VL_STIEL_LINIE=cellstr(VL_STIEL_LINIE_ROH);
> 5
> 6
> 7 VL_TEST=sprintf("String ->%s<-",VL_STIEL_LINIE(2))
>
> After executing the script in 3.0.5 we get this result: VL_TEST = String ->b<-
>
> In 3.2.4 we get this error:
>
> error: sprintf: wrong type argument `cell'
> error: called from:
> error:   ./rwu_test_sprintf.m at line 7, column 8
>
> (I added the line numbers above in the script for better reference to the error message)
>
> Anyone have an idea what's the problem?

_______________________________________________
Help-octave mailing list
[hidden email]
https://www-old.cae.wisc.edu/mailman/listinfo/help-octave
Reply | Threaded
Open this post in threaded view
|

Re: octave 3.2.4 - sprintf error message

Thomas Weber-3
In reply to this post by Michael.Eyer
On Fri, Oct 29, 2010 at 11:42:09AM +0200, [hidden email] wrote:
> Dear Users,
>
> we like to switch in the near future from Version 3.0.5 to 3.2.4 and getting an error message in the early tests with 3.2.4.

I suggest going directly to the 3.3 series (which should become stable
in the not too distant future). There won't be any more releases in the
3.2 series.

>
> We are using the following script in 3.0.5 and 3.2.4:
>
> # cat rwu_test_sprintf.m
> 1
> 2 VL_STIEL_LINIE_ROH=  ["a";"b";"c"];
> 3
> 4 VL_STIEL_LINIE=cellstr(VL_STIEL_LINIE_ROH);
> 5
> 6
> 7 VL_TEST=sprintf("String ->%s<-",VL_STIEL_LINIE(2))
>
> After executing the script in 3.0.5 we get this result: VL_TEST = String ->b<-
>
> In 3.2.4 we get this error:
>
> error: sprintf: wrong type argument `cell'
> error: called from:
> error:   ./rwu_test_sprintf.m at line 7, column 8
>
> (I added the line numbers above in the script for better reference to the error message)
>
> Anyone have an idea what's the problem?

VL_STIEL_LINIE is a cell array, so you must access its second element as
        VL_STIEL_LINIE{2}
(mind the braces) or convert it explicitely:
        cell2mat(VL_STIEL_LINIE(2))

        Thomas
_______________________________________________
Help-octave mailing list
[hidden email]
https://www-old.cae.wisc.edu/mailman/listinfo/help-octave