If I have a matrix where each column refers to depth and each row refers to days, how is it possible to find and keep the values in each column which is between 0 and 30. At the minute some of the values fall below 0 and others reach as high as 100. So how would I just keep the values between 0 and 30 in the same matrix and make every other value as NaN?
cheers

 채택된 답변

Wayne King
Wayne King 2011년 11월 17일

0 개 추천

X = randi([-5 110],10,10);
X(X<0 | X>30) = NaN;

댓글 수: 3

Mitch Martelli
Mitch Martelli 2011년 11월 17일
Hi wayne i would like to ask you in which version are added the randi function...later than R2007b?
Wayne King
Wayne King 2011년 11월 17일
@Mitch Martelli R2008b
Mitch Martelli
Mitch Martelli 2011년 11월 17일
Thanks a lot...you are very kind

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

추가 답변 (0개)

카테고리

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

태그

질문:

2011년 11월 17일

Community Treasure Hunt

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

Start Hunting!

Translated by