Hi, I import a data table textfile (usually there are several and it is looped) and have had some issues with it, I can overcome them but when I try to filter some data in the data column I am after (named 'trajectory_deg' in the original file but I separate it into a separate variable called traj) it will not allow it, telling me
"Undefined operator '>' for input arguments of type 'table'.Error in untitled3 (line 73) traj_copy((80>traj_copy)&(traj_copy>100))=NaN;"
In my workspace tray is class double, when I whos trap it tells me it is double, yet this problem persists, any ideas?
close allclear allclc%%Get files
Folder_used = dir('/Users/files4data/*.txt');files = Folder_used;amountFILES=numel(files);for k=1:amountFILES % for k=1:1
opts = detectImportOptions(files(k).name); data=readtable(files(k).name,opts); possibleTrajStr={'Trajectory_deg','trajectory','trajectory_deg','Trajectory','Traj_deg','traj'}; possibleNozStr={'ExpID','Exp_ID','Exp ID'}; headers_in_data =data.Properties.VariableNames; disp ************************************************************* %%*************************************************************
file=(files(k).name); left_color = [0 0 0]; right_color = [0 0 0]; set(figure,'defaultAxesColorOrder',[left_color; right_color],... 'units','normalized','outerposition',[0 0 1 1]); %%************************************************************* ColForm=varfun(@class,data,'OutputFormat','cell'); [ColIndexLog,ColIndexDouble]=ismember(ColForm,'cell') ; CellsInTable=find(ColIndexDouble); indices = find(abs(CellsInTable)>4); CellsInTable(indices) = []; for g=1:numel(CellsInTable) B=CellsInTable(g); C=(headers_in_data(B)); CCC=char(string(C{:})); XC=data.(CCC); dataLoop=XC; logicalIndex = ismember(dataLoop, 'UND. -60001'); dataLoop(logicalIndex) = {'NaN'}; S = sprintf('%s*', dataLoop{:}); N = sscanf(S, '%f*'); N2=array2table(N); data.(CCC)=(N2); end TrajOuty = ismember(headers_in_data,possibleTrajStr); [~,TrajColID] = find(TrajOuty); traj=data(:,TrajColID); traj=table2array(traj); whos traj traj_copy=traj; traj_copy((80>traj_copy)&(traj_copy>100))=NaN; traj_copy=(deg2rad(traj_copy-90))*1000; % traj((80>traj)&(traj>100))=NaN;
% traj=(deg2rad(traj-90))*1000;
end
Best Answer