how can i find specific elements from a 1xN array?

조회 수: 2 (최근 30일)
akash bais
akash bais 2017년 3월 15일
댓글: Jan 2017년 3월 15일
like from the image above i want to find 1's and 0's from an array and store sequentially in another array
  댓글 수: 1
Jan
Jan 2017년 3월 15일
EDITED: Move text from the tag to the question section.

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

채택된 답변

Jan
Jan 2017년 3월 15일
The question is avgue. Perhaps this helps:
Index = or(A == 0, A == 1);
result = B(Index);
  댓글 수: 2
akash bais
akash bais 2017년 3월 15일
i have tried this code in my program but have some issues your code provides output as follows.
55 3 2 1 -1 -1 -2 1 3
A=[55 2 1 0 -1 -1 -2 0 2]
index =
0 0 0 1 0 0 0 1 0
53 54
Expected output=[1 1] from indices 4 and 8
Jan
Jan 2017년 3월 15일
I do not understand you notation. A is a [1 x 9] vector, but what is the line on top? What dimension has your "index"? Please post the original code which runs by copy&paste.

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

추가 답변 (0개)

카테고리

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

태그

아직 태그를 입력하지 않았습니다.

Community Treasure Hunt

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

Start Hunting!

Translated by