MATLAB: Deleting several specific columns from a table

columnsdeletetable

I would like to delete several hundred columns from a table of data. I'm currently using the commands:
QuestionnairesData(:,4:5) = []
QuestionnairesData(:,5:6) = []
QuestionnairesData(:,6:7) = []
But this goes on for several hundred lines which would take hours to run. Does anyone know a more efficient way to do this? Thank you!

Best Answer

Do you know all the column indices you want to delete? It's as simple as
columnIndicesToDelete = [4 5 6 7 9 12 14 15 17]; % and so on
QuestionnairesData(:,columnIndicesToDelete) = [];
And if there is some pattern to the indices, you won't necessarily have to specify every single value.
Or am I missing something? In your example, the columns deleted in the command
QuestionnairesData(:,5:6) = [];
after having done
QuestionnairesData(:,4:5) = [];
will not be the 5th and 6th column of the original array. So maybe there is some complication there?