필터 지우기
필터 지우기

Find elements of a vector

조회 수: 2 (최근 30일)
Tom
Tom 2014년 2월 12일
댓글: Azzi Abdelmalek 2014년 2월 12일
If I have a vector, e.g.
A = [ 2 8 6 5 3 3 6 5 5 3 4 1 2 9 6]
How do I return a vector which just gives single examples of the elements of A, e.g.
B = [1 2 3 5 6 8 9]
Kind regards,
Tom

채택된 답변

Azzi Abdelmalek
Azzi Abdelmalek 2014년 2월 12일
편집: Azzi Abdelmalek 2014년 2월 12일
B=unique(A)
You can make the result without sorting
B=unique(A,'stable')
  댓글 수: 6
Tom
Tom 2014년 2월 12일
Sorry.
If I have a vector e.g.: B = [1 2 3 5 6 8 9]
I want to look through the elements of B
i.e. I tried:
for j = B
do something
end
But this doesn't seem to work...
Azzi Abdelmalek
Azzi Abdelmalek 2014년 2월 12일
That's depends on what (do something) is

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

추가 답변 (0개)

카테고리

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

Community Treasure Hunt

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

Start Hunting!

Translated by