How can I add " " to first row and column in a cell

7 ビュー (過去 30 日間)
Orongo
Orongo 2018 年 10 月 14 日
コメント済み: Orongo 2018 年 10 月 15 日
Hi, I have created a cell with average values of 100 simulations. Now I need to save this as a text file (space delimited or tab delimited) and append a first row dating each column 1996 to 2014 and append a column starting from 0 to 10. So the final file should look something like this
\begin{table}[]
\begin{tabular}{llllllllllllllllllll}
& "1996 & "1997 & "1998 & "1999 & "2000 & "2001 & "2002 & "2003 & "2004 & "2005 & "2006 & "2007 & "2008 & "2009 & "2010 & "2011 & "2012 & "2013 & "2014 \\
"0" & 50787.83 & 47436.17 & 46186.5 & 45683.67 & 46057.83 & 47013.17 & 48264.5 & 50231.5 & 51607.67 & 52102.5 & 53428.67 & 55074.83 & 55994.67 & 57143.67 & 58627 & 58441.5 & 57857.17 & 58500 & 59133.33 \\
"1" & 55247.83 & 50901.5 & 47571.67 & 46402.5 & 45965.5 & 46415.33 & 47408.67 & 48660.17 & 50574.5 & 51968.33 & 52603.17 & 53985.67 & 55702.67 & 56674.83 & 57777.5 & 59281.83 & 59128.83 & 58549.5 & 59263.67 \\
"2" & 58692.67 & 55244.67 & 50939.17 & 47694 & 46577.5 & 46207.17 & 46678.67 & 47649.67 & 48880.83 & 50775.33 & 52282.83 & 53033 & 54464.17 & 56212.83 & 57121.5 & 58207.17 & 59760.67 & 59717.5 & 59264.17 \\
"3" & 61737.83 & 58658.67 & 55259.67 & 51039.17 & 47897.5 & 46825.33 & 46469.67 & 46934.67 & 47869.67 & 49071.17 & 51068.5 & 52712.33 & 53502.67 & 54924.33 & 56576.83 & 57456.5 & 58620.17 & 60264.83 & 60328.33 \\
"4" & 64110 & 61690.83 & 58689.17 & 55348.83 & 51187.17 & 48127.17 & 47110.67 & 46742 & 47157.83 & 48042 & 49339.67 & 51444.67 & 53143.67 & 53971.17 & 55296 & 56903.17 & 57830 & 59098.33 & 60867 \\
"5" & 64941.67 & 64102.67 & 61705.83 & 58748.67 & 55470.33 & 51380.67 & 48350.83 & 47363.33 & 46974.17 & 47331 & 48271 & 49657.83 & 51813.33 & 53539.67 & 54313.67 & 55584 & 57231.33 & 58336.83 & 59693.5 \\
"6" & 63331.17 & 64964.67 & 64169.5 & 61790.83 & 58867.33 & 55665 & 51623.83 & 48565.17 & 47548.83 & 47146.33 & 47645.33 & 48727.33 & 50083.5 & 52207.67 & 53870.83 & 54582.17 & 55910.67 & 57733.5 & 58983.83 \\
"7" & 60858.5 & 63407.5 & 65060.67 & 64272.17 & 61933 & 59037.17 & 55857 & 51833 & 48756.33 & 47696.5 & 47368.83 & 47987 & 49111.83 & 50500.5 & 52593.5 & 54191.67 & 54927 & 56437.17 & 58374.83 \\
"8" & 58079.17 & 60920.17 & 63499.5 & 65189.17 & 64434 & 62126.83 & 59266.17 & 56080.67 & 52033.67 & 48955.5 & 47989.5 & 47762.33 & 48411.33 & 49530.17 & 50818.33 & 52839 & 54503.83 & 55453.67 & 57084.67 \\
"9" & 55710.67 & 58150 & 61031.33 & 63629 & 65354.67 & 64640.83 & 62343 & 59489.83 & 56297.5 & 52182.33 & 49200.33 & 48376.17 & 48182.17 & 48848.83 & 49914.5 & 51152.5 & 53205 & 55058.17 & 56106.83 \\
"10" & 54632.33 & 55824.67 & 58302.17 & 61172.17 & 63780.67 & 65538.17 & 64849 & 62576.83 & 59712 & 56481.33 & 52457.83 & 49606.5 & 48782.67 & 48564.83 & 49177.5 & 50207.5 & 51494 & 53744.83 & 55719.67
\end{tabular}
\end{table}
How can I write this in Matlab?
  3 件のコメント
Orongo
Orongo 2018 年 10 月 14 日
Hi Walter, yes there should be a double quote at end of the year number. This was a mistake.

サインインしてコメントする。

採用された回答

Guillaume
Guillaume 2018 年 10 月 14 日
Adding the headers to your cell array as you require is trivial:
newcellarray = [{}, compose('"%d', 1996:2014); compose('"%d", (1:10)'), yourcellarray]
  5 件のコメント
Orongo
Orongo 2018 年 10 月 15 日
Thank you for clarifying. I did modify you initial suggestion but it's not as clean as yours! Many thanks!

サインインしてコメントする。

その他の回答 (0 件)

製品


リリース

R2017a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by