How to delete a column with a specific value

8 vues (au cours des 30 derniers jours)
Jesse
Jesse le 5 Nov 2018
Commenté : madhan ravi le 7 Nov 2018
In my case i would like to delete specific columns where for example the minimum value is 2e11;
This code below doesn't work, i get this error: Matrix index is out of range for deletion.
Error in reactionforce_script (line 16) reactionforce(reactionforce(2:end,:) < thresholdmin | reactionforce(2:end,:) > thresholdmax, :) = []
code :
load ('Y:\Spoormodel\06\reactionforce2.mat');
%reactionforce2 = removevars(reactionforce, 3:2:end);
reactionforce2 = reactionforce;
reactionforce(4:2:end,:) = [];
reactionforce(:,3:2:end) = [];
%reactionforce(:,35:end) = []; %verwijderen van kolommen zonder waarde
reactionforce(1,:) = [];
reactionforce = table2array(reactionforce);
% thresholdmin = 2e11;
% thresholdmax = 2e30;
% reactionforce(reactionforce(2:end,:) < thresholdmin | reactionforce(2:end,:) > thresholdmax, :) = []
%
reactionforce = array2table(reactionforce);
time = table2array(reactionforce(2:end,1));
data = reactionforce(2:end,2:end);
data = table2array(data(1:end,1:end));
plot (time,data);
  3 commentaires
Jesse
Jesse le 5 Nov 2018
it is a 401x1032 table, these are some values
madhan ravi
madhan ravi le 5 Nov 2018
attach your .mat file

Connectez-vous pour commenter.

Réponse acceptée

Guillaume
Guillaume le 5 Nov 2018
Error in reactionforce_script (line 16)
reactionforce(reactionforce(2:end,:) < thresholdmin | reactionforce(2:end,:) > thresholdmax, :) = []
Well, yes that line is never going to work. If that line is meant to delete all rows for which any value in any columns but the first is outside the boundary, then:
reactionforce(any(reactionforce(2:end,:) < thresholdmin | reactionforce(2:end,:) > thresholdmax), :) = [];
  6 commentaires
Jesse
Jesse le 7 Nov 2018
Thanks for your help and excellent explanation, this is solving my problem.
madhan ravi
madhan ravi le 7 Nov 2018
+1 perfecto @Guillaume

Connectez-vous pour commenter.

Plus de réponses (1)

Jesse
Jesse le 5 Nov 2018
This is my file
  2 commentaires
Guillaume
Guillaume le 5 Nov 2018
Can you write that as a comment to the question, not an answer?
Jesse
Jesse le 5 Nov 2018
Next time i will do

Connectez-vous pour commenter.

Catégories

En savoir plus sur Logical dans Help Center et File Exchange

Produits


Version

R2018a

Community Treasure Hunt

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

Start Hunting!

Translated by