Deleting multiple rows based on a specific condition

조회 수: 20 (최근 30일)
Stefania Avvedimento
Stefania Avvedimento 2021년 2월 28일
댓글: KALYAN ACHARJYA 2021년 2월 28일
Hi all,
I am working on a water network. I got a big matrix 381x12527 (time vs node's quality concentration) even for times that I am not interest in. So I want to delete the matrix rows for which the difference between two consecutive rows is not equal to 3600 (see yellow rows in Figure).
I would appreciate if anyone could help me, thanks!
Stefania

채택된 답변

KALYAN ACHARJYA
KALYAN ACHARJYA 2021년 2월 28일
편집: KALYAN ACHARJYA 2021년 2월 28일
Lets say data1 is the column time data
diff_data=diff(data1);
idx_delete=find(diff_data~=3600)+1;
% +1 for compensate with next
% Do modify accordingly
Once get the rows numbers, which to be deleted
matrix(idx_delete,:)=[]
Or:
matrix(~mod(data1,3600)==0,:)=[]
It gives the all those numbers, which are non divisible by 3600
  댓글 수: 2
Stefania Avvedimento
Stefania Avvedimento 2021년 2월 28일
thank you Kalyan Acharjya for helping me :)
KALYAN ACHARJYA
KALYAN ACHARJYA 2021년 2월 28일
I'm glad it helped
:)

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Multidimensional Arrays에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by