MATLAB Answers

how can I select rows data from imported file

18 views (last 30 days)
Eman Saleem
Eman Saleem on 27 Jun 2019
Commented: Sura Raya on 27 Jun 2019
I have the following data from text file( Large data). I imported the file to matlab,
Small sample example of the data:
CATE VarName2 VarName3 VarName4 SATE
MODEL 2019 56 0 GPS
MODEL 2019 56 0 GPS
MODEL 2019 56 0 GPS
MEAS 2019 56 7650 GLO
M EAS 2019 56 7650 GPS
MEAS 2019 56 7650 GPS
MODEL 2019 56 0 GPS
MODEL 2019 56 0 GPS
MEAS 2019 56 7650 GPS
for example: from column (CATE) I want to choose the rows of MODEL only with out MEAS?
Also from column (SATE), if I want to choose all rows who has GPS only How I can do it?
The number of columns of 'MODEL row' are more than the number of columns in 'MEAS'.

  0 Comments

Sign in to comment.

Answers (1)

KSSV
KSSV on 27 Jun 2019
T = readtable(myfile) ;
idx = contains(T.CATE,'MODEL') ; % also have a look on strcmp
T(idx,:)

  3 Comments

Eman Saleem
Eman Saleem on 27 Jun 2019
Thank you , I have now the following error ( I use your code)
Warning: Table variable names were modified to make them valid MATLAB identifiers. The original names are saved in the VariableDescriptions property.
KSSV
KSSV on 27 Jun 2019
Attach your data. This can be resolved using options in readtable.
Sura Raya
Sura Raya on 27 Jun 2019
i have same error, since we use (.out) not text or excel and columns dont have id ( CATE VarName2 VarName3 VarName4 SATE ) unless we import it in matlab, and readtable doesn't accept this type of files.

Sign in to comment.

Sign in to answer this question.