I have an array with integers and non-integers. Is there a 'find' function where I can gather only the integers from the array?

 채택된 답변

Stephan
Stephan 2018년 5월 26일
편집: Stephan 2018년 5월 26일

2 개 추천

Hi,
try this:
A = [5 0.1 -3 -4 -0.5 9 0 11 12 5 0.5]
A =
Columns 1 through 5
5.0000 0.1000 -3.0000 -4.0000 -0.5000
Columns 6 through 10
9.0000 0 11.0000 12.0000 5.0000
Column 11
0.5000
B = A(round(A(:)) == (A(:)))
B =
5 -3 -4 9 0 11 12 5
Best regards
Stephan

댓글 수: 3

Edgar Diaz
Edgar Diaz 2018년 5월 26일
Thank you
Rucheru Naicker
Rucheru Naicker 2020년 3월 10일
Thanks this helped sooo much.
Luke Ramel
Luke Ramel 2023년 3월 10일
Thanks

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

도움말 센터File Exchange에서 Numeric Types에 대해 자세히 알아보기

질문:

2018년 5월 26일

댓글:

2023년 3월 10일

Community Treasure Hunt

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

Start Hunting!

Translated by