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일

1 개 추천

c=v(1:find(v<0,1,'first')-1)

추가 답변 (0개)

카테고리

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

제품

릴리스

R2017a

태그

질문:

2019년 2월 14일

답변:

2019년 2월 14일

Community Treasure Hunt

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

Start Hunting!

Translated by