"ismember" error with tall arrays

13 views (last 30 days)
HELLO_MA
HELLO_MA on 26 Jul 2017
Answered: Edric Ellis on 27 Jul 2017
I am using Matlab R2016b version and working with tall arrays. I have created a tall table and have also an in-memory cell array, lets' call it B.
I would like to keep only rows of my tall table where tt.Variable1 is found in the in-memory array B.
Thus, I am using function ismember, which is said to work with tall (https://nl.mathworks.com/help/matlab/import_export/functions-that-support-tall-arrays-a-z.html), quoting from the link: Input A must be a tall array, and input B must be an in-memory array. when I do
  1. idx= ismember(tt.Variable1, B)==1;
  2. tt = tt(idx,:);
I get an error: Input A of class tall and input B of class cell must be the same class, unless one is double.
How can I solve this?
SMALL EDIT: For more informatioin:
  • class(B)=cell
  • class(tt.Variable1)=tall
  • classUnderlying(tt.Variable1)=
  • 1×4 tall char array
  • cell

Accepted Answer

Edric Ellis
Edric Ellis on 27 Jul 2017
tall/ismember was only added in R2017a. See the R2016b list of supported functions if you cannot upgrade to R2017a. In R2017a, you can do stuff like this:
>> tt = tall(table({'a'; 'b'; 'c'; 'd'; 'e'}, rand(5, 1)))
tt =
5×2 tall table
Var1 Var2
____ _______
'a' 0.15761
'b' 0.97059
'c' 0.95717
'd' 0.48538
'e' 0.80028
>> B = {'c'; 'e'};
>> idx = ismember(tt.Var1, B);
>> tt(idx,:)
ans =
2×2 tall table
Var1 Var2
____ _______
'c' 0.95717
'e' 0.80028

More Answers (0)

Categories

Find more on Tables in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!