How to find min and its index in calendarDuration array

조회 수: 2 (최근 30일)
Bohdan Perviy
Bohdan Perviy 2020년 1월 29일
댓글: Bohdan Perviy 2020년 1월 29일
I got such an array and its min element has 8th index (the closest duraion). Min() function won't work. Apparently it needs some conversion
  댓글 수: 5
Mohammad Sami
Mohammad Sami 2020년 1월 29일
days = split(t,'days');
Bohdan Perviy
Bohdan Perviy 2020년 1월 29일
I moved back to the Duration class, because previously i used between() so that as a result i got calendarDuration array, but now i solved the problem using difference between Datetime array and Datetime value
% v1 = between(start_manvr, string(outcome(:,3)));
v1 = datetime(string(outcome(:,3))) - start_manvr
[c,index] = min(abs(v1));
Anyway, thanks for the tip about Duration class

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

답변 (0개)

카테고리

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

제품


릴리스

R2019a

Community Treasure Hunt

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

Start Hunting!

Translated by