removevars ERROR for a table
Show older comments
Hello gusy!
I am starting with new project for my wokr I I got stuck in the beggining.
I am making simple coda in app designer to load a CVS, delete some rows i dont need and then plot a resuts.
Having
Error using tabular/subsasgnParens (line 215)
A table variable subscript must be a numeric array containing real positive integers, a logical array, a character vector, a string array, or a cell array of character vectors.
Error in tabular/removevars (line 28)
a = move(a).subsasgnParens({':',vars},[],false,true);
[file,path,~] = uigetfile({'.csv'}); % open the dialog box,
% N = file; %create variable with the name of the document
%app.EditField.Value = N; % show document name in text filed
filename = [path file]; %combine path and name
A1= readtimetable(filename); %importing data to parameter AA as a table
%A1.Properties.VariableDescriptions % original names for variables from the logs, before MATLab changed them.
A2 = removevars(A1,{'Lon' 'Lat' 'GPSAltitude_m_' 'GPSTime' 'GPSHead' 'GPSSource' 'GPSDataInd' 'GPSArea' 'LTEKPIPCellServingEARFCN_DL_' ...
'LTEKPIPCellServingEARFCN_UL_' 'LTEKPIPCellServingBandWidthDL' 'LTEKPIPCellServingBandWidthUL' 'LTEKPIPCellPUSCHPowerdBm' 'LTEKPIPCellPUCCHPowerdBm' ...
'LTEKPIPCellSRSPowerdBm' 'LTEKPIPCellTotalTxPowerdBm' 'LTEKPIPCellWBCQICW0' 'LTEKPIPCellWBRI' 'LTEKPIPCellWBRI1Rate' 'LTEKPIPCellWBRI2Rate' ...
'LTEKPIPCellWBRI3Rate' 'LTEKPIPCellWBRI4Rate' 'LTEKPIPCellDLMCS0' 'LTEKPIPCellDLMCS1' 'LTEKPIPCellULMCS' 'LTEKPIPCellDLModulation0' ...
'LTEKPIPCellDLModulation1' 'LTEKPIPCellULModulation' 'LTEKPIPCellPDSCHPRBNumberTB0Including0' 'LTEKPIPCellPDSCHPRBNumberTB1Including0' ...
'LTEKPIPCellPUSCHPRBNumberIncluding0' 'LTEKPIPCellPDSCHBLER' 'LTEKPIPCellPUSCHBLER' 'LTEKPIPCellPUSCHThroughputMbps' 'LTEKPIPCellMACDLThroughputMbps' ...
'LTEKPIPCellMACULThroughputMbps' 'LTEKPIPDSCHPRBNumberAvgTotal' 'LTEKPIPUSCHPRBNumberAvgTotal' 'LTEKPIPDSCHPRBNumberIncluding0Total' ...
'LTEKPIPUSCHPRBNumberIncluding0Total' 'LTEKPIPDSCHBLER' 'LTEKPIPUSCHBLER' 'LTEKPIPDSCHThroughputMbps' 'LTEKPIPUSCHThroughputMbps' ...
'LTEKPIMACDLThroughputMbps' 'LTEKPIMACULThroughputMbps' 'LTEKPIRLCDLThroughputMbps' 'LTEKPIRLCULThroughputMbps' 'LTEKPIPDCPDLThroughputMbps' ...
'LTEKPIPDCPULThroughputMbps' 'LTEKPITAC' 'LTEKPICAType' 'LTEKPIULCAType' 'LTEKPIBandCombination' ...
'QualcommLteLteAdvIntrafreqMeasurePCellNeighborCellNeighborCellC' 'QualcommLteLteAdvIntrafreqMeasurePCellNeighborCellNeighborCellL' ...
'QualcommLteLteAdvIntrafreqMeasurePCellNeighborCellSummaryNeighb' 'QualcommLteLteAdvIntrafreqMeasurePCellNeighborCellNeighborMeasu'});
% delete all shitty collums I dont need

this is the CSV I am working with.
https://drive.google.com/drive/folders/1nCXV5Stf-5oMKg3asAsr2PF0YbLflIs3?usp=sharing
Please be kind and explaing stuff because I might be dumb :D
thanks
Accepted Answer
More Answers (2)
Cris LaPierre
on 24 Apr 2021
1 vote
I can't reproduce your error message, but I do get a different error. One of the variable names you are trying to remove does not exist in the file.
Unrecognized table variable name 'LTEKPIPCellServingBandWidthDL'.
a = move(a).subsasgnParens({':',vars},[],false,true);
How many variables does your timetable have and how many do you want to keep? If you only want to keep one or two, rather than removing a lot of variables you could just index and keep the ones you want. For a sample table:
load patients
patients = table(LastName,Gender,Age,Height,Weight,Smoker,Systolic,Diastolic);
I could remove all the variables except LastName and Age:
patients1 = removevars(patients, {'Gender', 'Height', 'Weight', 'Smoker', 'Systolic', 'Diastolic'});
Or I could keep LastName and Age:
patients2 = patients(:, {'LastName', 'Age'});
Let's check that we received the same results.
areTheyTheSame = isequal(patients1, patients2)
We did.
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!