Undefined function 'eq' for input arguments of type 'table'.

1 次查看(过去 30 天)
I have taken a random sample of 6000 out of a data set of 30000. I now want to remove this sample from my original dataset to conduct analysis on the now "new" 80% of the original. I am using the below code but getting the error above.
%%Randomly Select 6,000 observations (20%) without replacement
Test_data = datasample(Data,6000,'Replace',false);
TestData = array2table(Test_data);
Test_CustID = TestData(:,1);
sort1 = sortrows(Test_CustID,1);
for i = 1:6000;
Condition = sort1(i,1);
Sample = Data(:,1)==Condition;
Data(Sample,:)=[];
end

回答(1 个)

Peter Perkins
Peter Perkins 2018-3-28
Data(:,1) is an Nx1 table, and tables don't have math r relational operators defined on them. You need to compare the first variable in Data to condition. You could use Data{:,1}, but Data.Var1 would be much more readable. Actually, I have no idea what the first variable in your table is really called, substitute its real name for "Var1".

类别

Help CenterFile Exchange 中查找有关 Tables 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by