Extracting zeros from vectors

조회 수: 2 (최근 30일)
IBM watson
IBM watson 2018년 10월 24일
댓글: madhan ravi 2018년 10월 24일
I need to extract zeros from a vector while keeping the same order of elements in s.
Like this :
S=[1 0 0 2 3 0 0 0 2 1 0 4 0 0 0 0 1 0 2]
S1=[1 2 3 2 1 4 1 2]

채택된 답변

madhan ravi
madhan ravi 2018년 10월 24일
편집: madhan ravi 2018년 10월 24일
>> S=[1 0 0 2 3 0 0 0 2 1 0 4 0 0 0 0 1 0 2]
S =nonzeros(S)'
S =
Columns 1 through 13
1 0 0 2 3 0 0 0 2 1 0 4 0
Columns 14 through 19
0 0 0 1 0 2
S =
1 2 3 2 1 4 1 2
>>
  댓글 수: 1
madhan ravi
madhan ravi 2018년 10월 24일
if this is not what you are looking for let know

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

추가 답변 (1개)

Andrei Bobrov
Andrei Bobrov 2018년 10월 24일

카테고리

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

태그

Community Treasure Hunt

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

Start Hunting!

Translated by