필터 지우기
필터 지우기

I want to sort the positive integer values from a given values of real, rational, negative values in an array.

조회 수: 1 (최근 30일)
I want to sort the positive integer values from a given values of real, rational, negative values in an array. Suppose, I have a=[0.2, 0.78, -3, 10, 0.8, -6, 2, -5, 3, 0.6, 8 ] then answer should be a= 10, 2, 3, 8.

답변 (3개)

Adam
Adam 2016년 9월 22일
tol = 1e-5;
a = a( a > 0 & abs( floor(a) - a ) < tol );
should work I think. Certainly it works on your example vector

Andrei Bobrov
Andrei Bobrov 2016년 9월 22일
out = a(a > 0 & rem(a,1)==0)

KSSV
KSSV 2016년 9월 22일
편집: KSSV 2016년 9월 22일
a(a>1)
Also read about find.

카테고리

Help CenterFile Exchange에서 Shifting and Sorting Matrices에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by