How to keep only positive values in an array?

I have a sorted array with different values: -18 -13 0 8 51 133 255
I only keep the positive values : 0 8 51 133 255
How do i do this?

 Akzeptierte Antwort

per isakson
per isakson am 1 Sep. 2015
Bearbeitet: per isakson am 1 Sep. 2015

17 Stimmen

Given 1D-array, i.e a vector
>> A = [ -18 -13 0 8 51 133 255]
A =
-18 -13 0 8 51 133 255
>> B = A( A>=0 )
B =
0 8 51 133 255
>>

Weitere Antworten (0)

Kategorien

Mehr zu Images finden Sie in Hilfe-Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by