How can I extract data with respect to certain non numeric values

조회 수: 8 (최근 30일)
shellmcg
shellmcg 2016년 4월 13일
댓글: shellmcg 2016년 4월 18일
I have a csv file, which have numeric and non numeric columns. e.g the first, second and fourth column has numbers and the third column has letters i.e C,S,CA. I have imported the file and sorted the third (non-numeric) column so all the C, CA and S values are listed together. How can I extract rows of data that are associated with 'CA'? Thanks

채택된 답변

Image Analyst
Image Analyst 2016년 4월 17일
Use readtable() to read your data into a table. Then use ismember() to find out which rows have CA in them, then use that to filter the rows. If you don't understand, then attach your data (csv file).
  댓글 수: 4
shellmcg
shellmcg 2016년 4월 18일
Thanks Image Analysis. I am getting an error with readtable function 'Undefined function 'readtable' for input arguments of type 'char'. I have loaded my data but I seem to be missing the column names so if I wanted CAs out of column 2 could I use col2=t.(:,2) instead of col2 = t.atom_types? Cheers
shellmcg
shellmcg 2016년 4월 18일
Thanks Image Analysis. It worked!!

댓글을 달려면 로그인하십시오.

추가 답변 (1개)

Yuebin Zhou
Yuebin Zhou 2016년 4월 15일
  댓글 수: 1
shellmcg
shellmcg 2016년 4월 17일
Thanks Yuebin but I actually want to store all the data in the CA rows in a separate matrix

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Matrix Indexing에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by