Delete rows of a matrix based on specific column threshold values?

조회 수: 16 (최근 30일)
Mads Petersen
Mads Petersen 2021년 2월 13일
댓글: Mads Petersen 2021년 2월 14일
Hello Guys
I have a .xlsx matrix loaded in matlab (600x20 size). One of the colums define where the interesting parts is. Thats where the value is above a certain threshold.
Question is; How do i cut down my entire matrix so i still have all colums left?
Example:
A = [ 1 2 1 2 3 2 1
1 2 3 4 3 1 4
2 4 3 2 5 2 5
2 3 4 3 2 4 6
4 3 2 4 2 4 2]
Column 7 is the threshold vector. I need to cut away entire rows based on this threshold vector. If threshold is set to minimum 3, then the above matrix must look like this, where row 1 and row 5 is removed from new matrix:
A = [ 1 2 3 4 3 1 4
2 4 3 2 5 2 5
2 3 4 3 2 4 6]
The logs created can by very big. So i need a solution that works with "readtable" function.
Thank you! ;-)
Regards

채택된 답변

Jan
Jan 2021년 2월 13일
A = [ 1 2 1 2 3 2 1
1 2 3 4 3 1 4
2 4 3 2 5 2 5
2 3 4 3 2 4 6
4 3 2 4 2 4 2]
index = A(:, 7) < Thresh;
A(index, :) = [];
"i need a solution that works with "readtable" function."
Of course you can apply this to data imported by readtable . But there is no way to filter the data magically during the import.

추가 답변 (0개)

Community Treasure Hunt

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

Start Hunting!

Translated by