フィルターのクリア

Add row/column names to a matrix

11 ビュー (過去 30 日間)
Theodore
Theodore 2013 年 7 月 25 日
コメント済み: ahmed 2013 年 10 月 22 日
Hello! I've created a 24 x 12 matrix (24 is dynamic and will change with each .csv file I run through my for loop) and wanted to attach the years (minyear:maxyear) to the rows and months ('Jan' 'Feb' 'March' 'Apr' 'May' 'June' 'July' 'Aug' 'Sep' 'Oct' 'Nov' 'Dec') to the columns. What is the best way to do this? I've tried using colnames and the dataset feature with no success:
M = rand(5)
dataset({M 'FOO','BAR','BAZ','BUZZ','FUZZ'}, ...
'obsnames', {'ROW1','ROW2','ROW3','ROW4','ROW5'}
Error: Expression or statement is incorrect--possibly unbalanced (, {, or [.
I've also attempted the printrow function
printmat(M, 'My Matrix', 'ROW1 ROW2 ROW3 ROW4 ROW5', 'FOO BAR BAZ BUZZ FUZZ' )
Undefined function 'printmat' for input arguments of type 'double'. Any suggestions? Thanks!

採用された回答

Azzi Abdelmalek
Azzi Abdelmalek 2013 年 7 月 25 日
You've missed a bracket
M = rand(5)
dataset({M 'FOO','BAR','BAZ','BUZZ','FUZZ'}, ...
'obsnames', {'ROW1','ROW2','ROW3','ROW4','ROW5'})
  7 件のコメント
ahmed
ahmed 2013 年 10 月 22 日
opsss. I thought that I am using 14 :).. Thx alot.
ahmed
ahmed 2013 年 10 月 22 日
I have an extra question. Now its working great. but i want to save thses results into xls file, I tried this export(mat1,'XLSFile','mat1.xlsx') but I got this ndefined function or method 'export' for input arguments of type 'double'.
Error in ==> BIST1 at 52 export(mat1,'XLSFile','mat1.xlsx') .. Is there any clean way to convert to xls before name the lables and name them after xls conversion then using matlab to handle this ??

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeDescriptive Statistics についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by