Nicer output from simulations
3 views (last 30 days)
Show older comments
I am taking a Monte-Carlo course and so i have some output, the homework is all done but i would like to make the end product a bit nicer. At the moment my output looks like:
ans =
CMC: Mean of 0.9512 with 95% C.I: 0.8815 1.0210
ans =
Control variate: Mean of 0.9482 with 95% C.I: 0.89261.0038
ans =
Alpha = -2.2307. Rho = 0.6042. W_hat = 0.0932. True W = 0.0919
But what i would like it to look like is something more along the lines of a top row with "Method Mean LowerCI UpperCI" and then 2 lines under with the needed values. And if possible a line under that where instead of alpha there is an actual alpha symbol.
If anyone has some examples or suggestions it would be a big help :)
1 Comment
Answers (2)
tlawren
on 21 Sep 2012
Where do you want to the output to go? The command window, a file, or somewhere else?
Something like the following could work to get the formatted output to the command window. It's not elegant, but it does the trick.
hline = sprintf('MM LCI UCI\n'); % header line
dline1 = sprintf('%d %d %d\n', mm1, lci1, uc1); % date line 1
dline2 = sprintf('%d %d %d\n', mm2, lci2, uc2); % data line 2
disp([hline,dline1,dline2]); % display to command window
Look up sprintf and fprintf online for more information.
2 Comments
Star Strider
on 21 Sep 2012
I suggest you experiment with the horizontal tab: \t. It can help line up your columns.
Ryan G
on 26 Sep 2012
You may be interested in disp instead of sprintf (depending on application, see this answer. sprintf is far and away a much more powerful and flexible utility, but disp is a bit more easy to use and may help you see the issues that you have.
There are examples of monte carlo simulation that show how disp can be used. Not necessarily directly applying to the way you may want to use it, though.
0 Comments
See Also
Categories
Find more on Data Distribution Plots in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!