[Scilab-users] number od decimals with csvWrite

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

[Scilab-users] number od decimals with csvWrite

Hi
I want to write some data and export them with 

csvWrite

I need to have no more than 2 decimals for aesthetic reasons.

How can I set the number of decimals?

Thanks,

Simone Meroni

_______________________________________________
users mailing list
[hidden email]
http://lists.scilab.org/mailman/listinfo/users
Serge Steer-3 Serge Steer-3
Reply | Threaded
Open this post in threaded view
|

Re: number od decimals with csvWrite

The simplest way is to use round

A=rand(3,3);
B=round(100*A)/100;

Serge Steer
Le 25/06/2015 22:07, Simone Meroni a écrit :
Hi
I want to write some data and export them with 

csvWrite

I need to have no more than 2 decimals for aesthetic reasons.

How can I set the number of decimals?

Thanks,

Simone Meroni


_______________________________________________
users mailing list
[hidden email]
http://lists.scilab.org/mailman/listinfo/users


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

Re: number od decimals with csvWrite

Hi.
I suppose no need to use the round function. Use csvWrite:

A=rand(3,3);

csvWrite(A, 'file_with_A_data.txt', ' ', '.', "%.2e")

7.26e-01 2.32e-01 8.83e-01
1.99e-01 2.31e-01 6.53e-01
5.44e-01 2.16e-01 3.08e-01

By the way, if you want to use a comma as a decimal mark the fourth parameter should be ',':

csvWrite(A, 'file_with_A_data.txt', ' ', ',', "%.2e")


Stanislav


26.06.2015 12:09, Serge Steer пишет:
The simplest way is to use round

A=rand(3,3);
B=round(100*A)/100;

Serge Steer
Le 25/06/2015 22:07, Simone Meroni a écrit :
Hi
I want to write some data and export them with 

csvWrite

I need to have no more than 2 decimals for aesthetic reasons.

How can I set the number of decimals?

Thanks,

Simone Meroni


_______________________________________________
users mailing list
[hidden email]
http://lists.scilab.org/mailman/listinfo/users



_______________________________________________
users mailing list
[hidden email]
http://lists.scilab.org/mailman/listinfo/users


_______________________________________________
users mailing list
[hidden email]
http://lists.scilab.org/mailman/listinfo/users