Removing non integer values from an array.

조회 수: 7 (최근 30일)
Prayash Thapa
Prayash Thapa 2021년 2월 4일
답변: Stephen23 2021년 2월 4일
Is there a way to remove non integer values from an array?
This is not the full script but parts of it:
arr = [1, G1, G2, G3, G4, G5, G6, G7]; % Put into array
sor_arr = [sort(arr)]; % Order numbers in that array
sor_arr(sor_arr<=1)=1 % Remove any thing below integer 1
uni_no = unique(sor_arr); % Remove duplicates
Assuming the variables are assigned to values which are integers and non integers.
I would like to know a way to remove non integers from the array.

답변 (1개)

Stephen23
Stephen23 2021년 2월 4일
V = [1,23,pi,4,5.6]
V = 1×5
1.0000 23.0000 3.1416 4.0000 5.6000
V(fix(V)~=V) = []
V = 1×3
1 23 4

카테고리

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