Extracting value from array and determine it position

suppose i have this table.
How do i determine how many days the temp in lake A was above 60 and on what day its happen? I use this commands but it doesnt satisfy my question.
temp_A=[55 62 60 61 63 65 62 59 58 56];
x=find(temp_A>60)
x = 1×5
2 4 5 6 7
position=temp_A(x)
position = 1×5
62 61 63 65 62

댓글 수: 4

David Fletcher
David Fletcher 2021년 5월 7일
편집: David Fletcher 2021년 5월 7일
Depends on what you mean by 'what day does it happen' - if you mean the first day it went above 60, then it will relate to the first value of x. Providing the days always increment from 1 by a single day then it will just be the value of x(1) - otherwise you will have to use the value of x(1) to index the day. The number of days above 60 is just the number of elements in x
I want it to list the the day when the temp above 60. Like this,
Day_when_its_above_60=[2 4 5 6 7]
I edited your post to show the results of running your computation. It seems to give exactly the results you say you expect. Are you seeing something different?
Ohhh i see, i need to separate the commands. Thanks for correcting me!!

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

답변 (0개)

카테고리

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

제품

릴리스

R2021a

태그

질문:

2021년 5월 7일

댓글:

2021년 5월 7일

Community Treasure Hunt

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

Start Hunting!

Translated by