how to remove negative numbers from a vector

조회 수: 52 (최근 30일)
KIRAN MUKUND
KIRAN MUKUND 2016년 2월 17일
편집: Stephen23 2016년 2월 17일
Hi,
Let
A=[5 -0.4 0.1 0 100 -10]
in that i want to remove all -ve numbers and print refined vector A
please help !!!! -kiran mukund-

답변 (1개)

Stephen23
Stephen23 2016년 2월 17일
편집: Stephen23 2016년 2월 17일
Use basic logical indexing:
>> A(A>=0)
ans =
5 0.1 0 100

카테고리

Help CenterFile Exchange에서 Operators and Elementary Operations에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by