필터 지우기
필터 지우기

Delete row in matrix and move

조회 수: 2 (최근 30일)
Sebastian
Sebastian 2018년 8월 2일
댓글: KALYAN ACHARJYA 2018년 8월 2일
Hi, I have Matrix [500000 rows x 3 columns]. In 3 columns are data from -1100 to +1000. I want delete a row if in 3 columns data are < -900. Next I'd like to move another rows in a place of deleted column and wrie as a new matrix. For example:
A=[20 30 40; 20 40 -930; 30 40 600];
In the 2nd row in 3d column is -930. I'd like to have
B=[20 30 40; 30 40 600];
Thanks for your help
  댓글 수: 1
KALYAN ACHARJYA
KALYAN ACHARJYA 2018년 8월 2일
'3 columns data are' means individual data or all elements data?

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

채택된 답변

KALYAN ACHARJYA
KALYAN ACHARJYA 2018년 8월 2일
편집: KALYAN ACHARJYA 2018년 8월 2일
Let assume matrix M, It deletes the rows having element less than -900
M(M(:, 3)<-900, :)=[]
  댓글 수: 2
Sebastian
Sebastian 2018년 8월 2일
Thnx it works perfectly!
KALYAN ACHARJYA
KALYAN ACHARJYA 2018년 8월 2일
Its my pleasure

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

추가 답변 (1개)

Jitender Gangwar
Jitender Gangwar 2018년 8월 2일
Hello Sebastian,
I understand you want to remove the rows containing values less than -900. I believe this can be achieved by using the 'find' function.
Hereby is an illustrative code for your reference:
A = [20 30 40; 20 40 -930; 30 40 600];
[r, c] = find(A < -900);
A(r, :) = [];
I hope this answers your query.

카테고리

Help CenterFile Exchange에서 Introduction to Installation and Licensing에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by