From: Hans on
Hello everybody


How can I get sprintf to a write a string in latex?

Example:

y_1=[1 2 3 4]
sprintf('%.0f \alpha\n', y_1)

It must be a string output

Best Regards

Hans
From: kinor on
"Hans " <jyde_6(a)msn.com> wrote in message <hj111c$ego$1(a)fred.mathworks.com>...
> Hello everybody
>
>
> How can I get sprintf to a write a string in latex?
>
> Example:
>
> y_1=[1 2 3 4]
> sprintf('%.0f \alpha\n', y_1)
>
> It must be a string output
>
> Best Regards
>
> Hans

Hi Hans,

hope

sprintf('%.0f \\alpha\n', y_1)

does it

kinor
From: Bruno Luong on
"Hans " <jyde_6(a)msn.com> wrote in message <hj111c$ego$1(a)fred.mathworks.com>...
> Hello everybody
>
>
> How can I get sprintf to a write a string in latex?
>
> Example:
>
> y_1=[1 2 3 4]
> sprintf('%.0f \alpha\n', y_1)
>

Replace \ with \\

Bruno
From: Hans on
"Bruno Luong" <b.luong(a)fogale.findmycountry> wrote in message <hj13g3$k23$1(a)fred.mathworks.com>...
> "Hans " <jyde_6(a)msn.com> wrote in message <hj111c$ego$1(a)fred.mathworks.com>...
> > Hello everybody
> >
> >
> > How can I get sprintf to a write a string in latex?
> >
> > Example:
> >
> > y_1=[1 2 3 4]
> > sprintf('%.0f \alpha\n', y_1)
> >
>
> Replace \ with \\
>
> Bruno

Hi Bruno and kinor

If I try:

y_1=[1 2 3 4]
sprintf('%.0f \\alpha\n', y_1)

I get :
>> sprintf('%.0f \\alpha\n', y_1)

ans =

1 \alpha
2 \alpha
3 \alpha
4 \alpha

I want it to show the alpha in symbol?

Best Regards

Hans
From: Bruno Luong on
"Hans " <jyde_6(a)msn.com> wrote in message <hj1bmj$9an$1(a)fred.mathworks.com>...
> "Bruno Luong" <b.luong(a)fogale.findmycountry> wrote in message <hj13g3$k23$1(a)fred.mathworks.com>...
> > "Hans " <jyde_6(a)msn.com> wrote in message <hj111c$ego$1(a)fred.mathworks.com>...
> > > Hello everybody
> > >
> > >
> > > How can I get sprintf to a write a string in latex?
> > >
> > > Example:
> > >
> > > y_1=[1 2 3 4]
> > > sprintf('%.0f \alpha\n', y_1)
> > >
> >
> > Replace \ with \\
> >
> > Bruno
>
> Hi Bruno and kinor
>
> If I try:
>
> y_1=[1 2 3 4]
> sprintf('%.0f \\alpha\n', y_1)
>
> I get :
> >> sprintf('%.0f \\alpha\n', y_1)
>
> ans =
>
> 1 \alpha
> 2 \alpha
> 3 \alpha
> 4 \alpha
>
> I want it to show the alpha in symbol?

You confuse, sprintf format the simple *string* (char array), the TeX/LaTex interpretation come later, when the string is used in graphic command such as XLABEL, TITLE...

Bruno