Nicer output from simulations
조회 수: 2 (최근 30일)
이전 댓글 표시
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 :)
답변 (2개)
tlawren
2012년 9월 21일
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
Star Strider
2012년 9월 21일
I suggest you experiment with the horizontal tab: \t. It can help line up your columns.
Ryan G
2012년 9월 26일
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
참고 항목
카테고리
Help Center 및 File Exchange에서 Data Distribution Plots에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!