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

1 回表示 (過去 30 日間)
Hugh Gray
Hugh Gray 2018 年 3 月 26 日
編集済み: Walter Roberson 2018 年 3 月 28 日
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 Center および File ExchangeTables についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by