how to remove negative numbers from a vector

43 次查看(过去 30 天)
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