how to remove negative numbers from a vector

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 日

5 投票

Use basic logical indexing:
>> A(A>=0)
ans =
5 0.1 0 100

カテゴリ

ヘルプ センター および File ExchangeOperators and Elementary Operations についてさらに検索

質問済み:

2016 年 2 月 17 日

編集済み:

2016 年 2 月 17 日

Community Treasure Hunt

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

Start Hunting!

Translated by