Reputation: 7004
I have a table with different type of columns. I am exporting this to excel with the function writetable(...)
. I was however wondering how I could display some columns in a different format.
E.g. the format in % rounded up to 2 integers. E.g. 0.025
--> 2.5%
.
T = table;
T.('Test') = rand(100,1,1);
Upvotes: 0
Views: 444
Reputation: 547
The easiest way is if it is formatted like that in your table. You can also open excel via Matlab and programmatically format it there but it's a lot more cumbersome.
t = array2table(rand(3))
t.(3) = cellstr(num2str(t.(3)*100, '%4.2f%%'))
writetable(t, 'test.csv')
t =
Var1 Var2 Var3
_______ ________ _______
0.73634 0.70405 0.33086
0.39471 0.44231 0.42431
0.68342 0.019578 0.27027
t =
Var1 Var2 Var3
_______ ________ ________
0.73634 0.70405 '33.09%'
0.39471 0.44231 '42.43%'
0.68342 0.019578 '27.03%'
Upvotes: 3