Removing specific numbers from a vector?

I need to write a function script that will identify numbers in a vector that are greater than 255 and remove them when I call the function. The Vector that I need to write the function for is: V = [2 5 378 8 633 12 18 24 974 35 56 257 89]

답변 (2개)

Walter Roberson
Walter Roberson 2017년 10월 29일

0 개 추천

Use logical indexing with V>255

댓글 수: 1

Walter Roberson
Walter Roberson 2017년 10월 29일
Be careful about what is removed (as in discarded) and what is kept. Be careful about NaN: NaN are not larger than 255 and they are also not smaller than 255 or equal to 255 either.

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

Image Analyst
Image Analyst 2017년 10월 29일

0 개 추천

I don't know what you mean by "function script". Try this if you want a function:
function newV = Remove255(V)
newV = V(V>255);

카테고리

도움말 센터File Exchange에서 Data Type Conversion에 대해 자세히 알아보기

태그

질문:

2017년 10월 29일

댓글:

2017년 10월 29일

Community Treasure Hunt

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

Start Hunting!

Translated by