negative number in vector

조회 수: 15 (최근 30일)
bsta
bsta 2019년 2월 14일
답변: madhan ravi 2019년 2월 14일
say I have a vector v=[1 2 5 6 -8 5 2 7]
and I to create a new vector that has all the elements until the negative number shows up
such as c=[1 2 5 6]
how would you do this without using a while loop

채택된 답변

madhan ravi
madhan ravi 2019년 2월 14일
c=v(1:find(v<0,1,'first')-1)

추가 답변 (0개)

카테고리

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

태그

제품


릴리스

R2017a

Community Treasure Hunt

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

Start Hunting!

Translated by