2011-12-09 53 views
1

提取單個列我有一個從MATLAB寫的是這樣的程序生成的矩陣:從矩陣

 'A'    'B'    'C'    'D'   'E' 
    [  4] [   1] [ 0.9837] [  0.9928] [0.9928] 
    [  4] [   1] [ 0.9995] [  0.9887] [0.9995] 
    [  4] [   1] [ 0.9982] [  0.9995] [0.9995] 
    [  4] [   1] [ 0.9959] [  0.9982] [0.9887] 

我試圖提取柱'D'無頭「d」。

我可以把一個臨時變量,然後提取列數據。但我想知道,如果可以一步完成的話。

感謝

+0

你能告訴我你的數據的類型?例如。 'whos(foo)' – alexplanation

+0

其單元矩陣 – Kiran

回答

6

如果變量是data,然後data(2:end,4)應該這樣做。


編輯:

例如:

>> data 
data = 
    'A' 'B' 'C'   'D'   'E'  
    [4] [1] [0.9837] [0.9928] [0.9928] 
    [4] [1] [0.9995] [0.9887] [0.9995] 
    [4] [1] [0.9982] [0.9995] [0.9995] 
    [4] [1] [0.9959] [0.9982] [0.9887] 
>> data(2:end,4) %Extract the data as a cell array 
ans = 
    [0.9928] 
    [0.9887] 
    [0.9995] 
    [0.9982] 
>> cell2mat(data(2:end,4)) %Convert to a numeric (typical) array 
ans = 
    0.9928 
    0.9887 
    0.9995 
    0.9982 
+0

非常感謝..這就是我正在尋找的東西。再次感謝您的幫助和時間。 – Kiran