필터 지우기
필터 지우기

how to find a value from a timeseries?

조회 수: 30 (최근 30일)
Tony Castillo
Tony Castillo 2018년 7월 16일
편집: Guillaume 2018년 7월 16일
hi Guys, I got a problem analyzing a time series, because of its length I need to find out a way to obtain the required value without need to scroll all the time series. For instance, how to find from the attached time series the value 79?, it must appear twice in the same time series?. Could you help me?.
  댓글 수: 2
KSSV
KSSV 2018년 7월 16일
The values are 69.9 and 70, there is no 79 in the data.
Tony Castillo
Tony Castillo 2018년 7월 16일
Oh, I think I have attached the wrong time series, but surely you could check the value 70, it appears twice. How do you do? Thanks in advance

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

채택된 답변

KSSV
KSSV 2018년 7월 16일
Go for logical indexing:
S = load('soc.mat') ;
t = S.soc.Time ;
y = S.soc.Data ;
idx = abs(y-70)<10^-5 ;
[t(idx) y(idx)]
  댓글 수: 3
KSSV
KSSV 2018년 7월 16일
I want to get y values which are equal to 70. So I need to check which values of y are equal to 70 an pick those indices. To compare floating point numbers it is suggested to use abs(y-val)<tolerance. 10^-5 is a tolerance factor, so I am picking those values from y on subtracting from 70, the difference should be less then tolerance.
Guillaume
Guillaume 2018년 7월 16일
편집: Guillaume 2018년 7월 16일
Do a search on floating point comparison to learn all about it.
To check that two floating point numbers are equal, you check that there difference is sufficiently small that you can consider them the same. KSSV chose 10e-5 for that sufficiently small difference. It's arbitrary, the value being informed by the magnitude of the numbers and the precision that you require.
Note that you musn't use == to compare floating point numbers, due to the limited precision inheritent to storing floating point numbers on a computer. In particular, a computer will tell you that
(0.1 + 0.1 + 0.1) == 0.3
is false, as computers can't store 0.1 exactly.
Again, do a search to learn more.

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

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Logical에 대해 자세히 알아보기

제품


릴리스

R2017a

Community Treasure Hunt

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

Start Hunting!

Translated by