matlab - extract a single column from a matrix - stack overflow

2
Kiran 1,890 9 52 100 1 Answer active oldest votes 1 1 I have a matrix generated from the program written in Matlab something like this : '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] I am trying to extract the column 'D' without the header 'D'. I can put into a temporary variable and then extract the column data. But I am wondering, if it could be done in a single step. Thanks matlab matrix share improve this question asked Dec 9 '11 at 14:32 Can you tell me the type of your data? E.g. whos(foo) alexplanation Dec 9 '11 at 14:38 Its a cell matrix – Kiran Dec 9 '11 at 14:41 5 If your variable is data , then data(2:end,4) should do it. Edit: For example: Extract a single column from a matrix add a comment

Upload: pand2406

Post on 02-Oct-2015

216 views

Category:

Documents


3 download

DESCRIPTION

asddf

TRANSCRIPT

  • 01/04/2015 matlabExtractasinglecolumnfromamatrixStackOverflow

    data:text/htmlcharset=utf8,%3Cdiv%20id%3D%22questionheader%22%20style%3D%22margin%3A%200px%200px%201em%3B%20padding%3A%205px 1/2

    Kiran1,890 9 52 100

    1Answer active oldest votes

    1

    1

    IhaveamatrixgeneratedfromtheprogramwritteninMatlabsomethinglikethis:

    '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]

    Iamtryingtoextractthecolumn 'D' withouttheheader'D'.

    Icanputintoatemporaryvariableandthenextractthecolumndata.ButIamwondering,ifitcouldbedoneinasinglestep.

    Thanks

    matlab matrix

    share improvethisquestion askedDec9'11at14:32

    Canyoutellmethetypeofyourdata?E.g. whos(foo) alexplanationDec9'11at14:38

    Itsacellmatrix Kiran Dec9'11at14:41

    5

    Ifyourvariableis data ,then data(2:end,4) shoulddoit.

    Edit:

    Forexample:

    Extractasinglecolumnfromamatrix

    addacomment

    http://stackoverflow.com/questions/8446968/extract-a-single-column-from-a-matrix?answertab=oldest#tab-tophttp://stackoverflow.com/posts/8446968/edithttp://stackoverflow.com/users/276859/kiranhttp://stackoverflow.com/users/276859/kiranhttp://stackoverflow.com/q/8446968http://stackoverflow.com/users/1075864/alexplanationhttp://stackoverflow.com/questions/8446968/extract-a-single-column-from-a-matrix#http://stackoverflow.com/users/276859/kiranhttp://stackoverflow.com/questions/8446968/extract-a-single-column-from-a-matrix?answertab=active#tab-tophttp://stackoverflow.com/questions/8446968/extract-a-single-column-from-a-matrix?answertab=votes#tab-tophttp://stackoverflow.com/questions/tagged/matlabhttp://stackoverflow.com/questions/8446968/extract-a-single-column-from-a-matrix#comment10440884_8446968http://stackoverflow.com/questions/tagged/matrixhttp://stackoverflow.com/questions/8446968/extract-a-single-column-from-a-matrix#comment10440839_8446968http://stackoverflow.com/questions/8446968/extract-a-single-column-from-a-matrix
  • 01/04/2015 matlabExtractasinglecolumnfromamatrixStackOverflow

    data:text/htmlcharset=utf8,%3Cdiv%20id%3D%22questionheader%22%20style%3D%22margin%3A%200px%200px%201em%3B%20padding%3A%205px 2/2

    >>datadata='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)%Extractthedataasacellarrayans=[0.9928][0.9887][0.9995][0.9982]>>cell2mat(data(2:end,4))%Converttoanumeric(typical)arrayans=0.99280.98870.99950.9982