how to delete particular row in given matrix ?

조회 수: 1 (최근 30일)
Matlab111
Matlab111 2014년 11월 4일
편집: Matlab111 2014년 11월 4일
like this matrix
a=[190.6412 159.7899 0.9991];
b=[180.1084 166.6349 0.9992
190.6412 159.7899 0.9991
179.5966 155.4710 1.0000
196.5314 166.2689 1.0000];
than the answer should be like this
c= [180.1084 166.6349 0.9992
179.5966 155.4710 1.0000
196.5314 166.2689 1.0000];
i should delete only 'a' matrix from the 'b' matrix and display as 'c' matrix

채택된 답변

Azzi Abdelmalek
Azzi Abdelmalek 2014년 11월 4일
편집: Azzi Abdelmalek 2014년 11월 4일
c=setdiff(b,a,'rows')
  댓글 수: 10
Image Analyst
Image Analyst 2014년 11월 4일
And this works just fine :
a=[190.6412 159.7899 0.9991];
b=[180.1084 166.6349 0.9992
190.6412 159.7899 0.9991
150.6412 169.7899 0.9995
179.5966 155.4710 1.0000
196.5314 166.2689 1.0000];
c=setdiff(b,a,'rows')
No error whatsoever. Please post the ACTUAL REAL code you are using, not this code that you just did, which works perfectly fine.
Matt Tearle
Matt Tearle 2014년 11월 4일
You seem to be saying that the number of columns of b will vary, but above you also said that 'b' will be like 'nx3 matrix', which means that b will always have 3 columns. And the example you keep showing has 3 columns.
So, again, you need to tell us what behavior you expect for b: should b always have 3 columns, or can the number of columns of b change?

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

추가 답변 (1개)

the cyclist
the cyclist 2014년 11월 4일
Here's one way:
tf = ismember(b,a,'rows')
c = b(not(tf),:)
  댓글 수: 1
Matlab111
Matlab111 2014년 11월 4일
편집: Matlab111 2014년 11월 4일
it's showing Error "A and S must have the same number of columns." in my case 'a' matrix will be same but 'b'matrix will get varies.

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

카테고리

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

Community Treasure Hunt

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

Start Hunting!

Translated by