[Scilab-users] xstring + format decimal number.

classic Classic list List threaded Threaded
4 messages Options
Marcus Vinicius P. de Souza Marcus Vinicius P. de Souza
Reply | Threaded
Open this post in threaded view
|

[Scilab-users] xstring + format decimal number.

Dear all,
I am not getting to formate strings using xstring command. For example:

Mp=54.5666666

xstring(1,1,'$\LARGE Mp={'+string(Mp)+'}\%$')

I want only: Mp=54.56%
How do I do?
Besides this, it is possible to define some position using "xstring" only by
click in figure?
"Fontsize" command doesn't work in xstring?
Can anybody help me?
Best regards.




--
Sent from: http://mailinglists.scilab.org/Scilab-users-Mailing-Lists-Archives-f2602246.html
_______________________________________________
users mailing list
[hidden email]
http://lists.scilab.org/mailman/listinfo/users
Dang Ngoc Chan, Christophe Dang Ngoc Chan, Christophe
Reply | Threaded
Open this post in threaded view
|

Re: xstring + format decimal number.

Hello,

> De : Marcus Vinicius P. de Souza
> Envoyé : jeudi 25 mars 2021 18:20
>
> Mp=54.5666666
> [...]
> I want only: Mp=54.56%
> How do I do?

I suggest o use floor() (truncate) or round(), e.g.

xstring(1, 1, '$\LARGE Mp={' + string(0.01*floor(100*Mp)) + '}\%$')

or use msprintf() (rounding), e.g.

xstring(0, 1, '$\LARGE Mp={' + msprintf("%2.2f", Mp) + '}\%$')

HTH

Regards


--
Christophe Dang Ngoc Chan
Mechanical calculation engineer

General
This e-mail may contain confidential and/or privileged information. If you are not the intended recipient (or have received this e-mail in error), please notify the sender immediately and destroy this e-mail. Any unauthorized copying, disclosure or distribution of the material in this e-mail is strictly forbidden.
_______________________________________________
users mailing list
[hidden email]
http://lists.scilab.org/mailman/listinfo/users
mottelet mottelet
Reply | Threaded
Open this post in threaded view
|

Re: xstring + format decimal number.

In reply to this post by Marcus Vinicius P. de Souza
Hi,

Le 25/03/2021 à 18:19, Marcus Vinicius P. de Souza a écrit :

> Dear all,
> I am not getting to formate strings using xstring command. For example:
>
> Mp=54.5666666
>
> xstring(1,1,'$\LARGE Mp={'+string(Mp)+'}\%$')
>
> I want only: Mp=54.56%
> How do I do?
> Besides this, it is possible to define some position using "xstring" only by
> click in figure?
> "Fontsize" command doesn't work in xstring?
> Can anybody help me?

For the two last points see my answers on StackOverflow (please avoid
cross-posting in the future):

https://stackoverflow.com/questions/66808702/xstring-format-decimal-number-scilab

S.

--
Stéphane Mottelet
Ingénieur de recherche
EA 4297 Transformations Intégrées de la Matière Renouvelable
Département Génie des Procédés Industriels
Sorbonne Universités - Université de Technologie de Compiègne
CS 60319, 60203 Compiègne cedex
Tel : +33(0)344234688
http://www.utc.fr/~mottelet

_______________________________________________
users mailing list
[hidden email]
http://lists.scilab.org/mailman/listinfo/users
Marcus Vinicius P. de Souza Marcus Vinicius P. de Souza
Reply | Threaded
Open this post in threaded view
|

Re: xstring + format decimal number.

In reply to this post by Dang Ngoc Chan, Christophe
Dear Christophe,
Excellent!!
Thanks a lot!!
Best regards!!
MV



--
Sent from: http://mailinglists.scilab.org/Scilab-users-Mailing-Lists-Archives-f2602246.html
_______________________________________________
users mailing list
[hidden email]
http://lists.scilab.org/mailman/listinfo/users