MATLAB Answers

accessing specific records of a given dataset

1 view (last 30 days)
Sebastiano delre
Sebastiano delre on 15 Jan 2014
Commented: Sebastiano delre on 15 Jan 2014
Hello! I have the following 5x4 dataset, called DB:
val =
line title replyno author
1 'Avensis' 1 'lui'
1 'Avensis' 2 'tu'
2 'Costs' 1 'pasquale'
2 'Costs' 2 'io'
2 'Costs' 3 'pasquale'
I want to access only records whose author is 'pasquale'. How can I do? I use new_DB = DB(DB.author=='pasquale'), but it does not work, it tells me "Undefined function 'eq' for input arguments of type 'cell'".
Thank you!

  1 Comment

Sebastiano delre
Sebastiano delre on 15 Jan 2014
I got it, I had to make the variable author nominal first: DB.author=nominal(DB.author). Then it works. Thanks anyway!

Sign in to comment.

Answers (1)

Image Analyst
Image Analyst on 15 Jan 2014
Try strcmpi(), strfind(), or ismember(). Try char() if you need to convert a cell into a character string. Disclaimer: I don't work with dataset class of variables.

  0 Comments

Sign in to comment.

Sign in to answer this question.