How to delete a column with a specific value
조회 수: 4 (최근 30일)
이전 댓글 표시
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
채택된 답변
Guillaume
2018년 11월 5일
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
추가 답변 (1개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Tables에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!