Could you help me solving the question regarding to coordinates, please?

Let's say I have such points:
  • A=(2,4)
  • B=(2,10)
  • C=(2,15)
  • D=(5,14)
  • E=(6,7)
  • F=(6,15)
  • G=(8,16)
  • H=(8,10)and I just want to select unique points which are A,B,C,D,E and G. I want to eliminate F and H because I've already used 6 in E and 15 in C for F; 8 in G and 10 in B.
Thanks for your time!

댓글 수: 2

Ok you mean so that you can perform operations like,?
M(allSelectedPoints) = 42;
I just want to select/see the points (A,B,C,D,E and G)eliminating F and H. Is there any way to do that?

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

 채택된 답변

Mischa Kim
Mischa Kim 2014년 3월 17일
편집: Mischa Kim 2014년 3월 17일
Rengin, use
data = [2,4;
2,10;
2,15;
5,14;
6,7;
6,15;
8,16;
8,10];
[C,ia,ic] = unique(data(:,2));
data_elim = sortrows(data(ia,:),1)
Addendum: the below snippet shows how to read from and write to an Excel file.
data = xlsread('test.xlsx',1); % read from sheet 1
[C,ia,ic] = unique(data(:,2));
data_elim = sortrows(data(ia,:),1);
xlswrite('test.xlsx',data_elim,2); % write to sheet 2

댓글 수: 4

I am sending my data file as excel with what I want to see and results after your recommendation. I cannot get some elements which I want to see. I filled some of them with yellow as examples. Why do I meet such a problem?
Thank you for your help.
You forgot to attach your workbook. Also, please be aware of the FAQ when comparing floating point numbers instead of integers: http://matlab.wikia.com/wiki/FAQ#Why_is_0.3_-_0.2_-_0.1_.28or_similar.29_not_equal_to_zero.3F
I see. This one produces the result you're looking for:
data_elim = data;
for ii = 2:length(data(:,1))
if sum(ismember(data(ii,:),data(1:ii-1,:))) == 2
data_elim(ii,:) = [NaN NaN];
end
end
data_elim(all(isnan(data_elim(:,1)),2),:) = [];
Thank you so much Mischa!

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

추가 답변 (0개)

카테고리

도움말 센터File Exchange에서 Logical에 대해 자세히 알아보기

질문:

2014년 3월 17일

댓글:

2014년 3월 18일

Community Treasure Hunt

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

Start Hunting!

Translated by