필터 지우기
필터 지우기

Intersect 2 arrays to find a position

조회 수: 1 (최근 30일)
Inês Mendes
Inês Mendes 2015년 6월 2일
댓글: Inês Mendes 2015년 6월 2일
I have 3 vectors like these:
hour=[8 8 8 9 9 9]
Minute=[15 30 45 15 30 45]
V=[10 6 5 4 3 11]
How do I intersect the first 2 in order to find the position to extract the value from de V vector.
For example: I want to extract all values starting at 8.45h

채택된 답변

Azzi Abdelmalek
Azzi Abdelmalek 2015년 6월 2일
hour=[8 8 8 9 9 9]
Minute=[15 30 45 15 30 45]
V=[10 6 5 4 3 11]
s='8.45'
ii=cellfun(@str2num,strsplit(s,'.'))
id=find(hour==ii(1) & Minute==ii(2))
out=V(id:end)
  댓글 수: 2
Jan
Jan 2015년 6월 2일
A simplification:
ii = sscanf(s, '%d.%d')
Inês Mendes
Inês Mendes 2015년 6월 2일
Thank you Azzi and Jan! You helped a lot :)

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

추가 답변 (1개)

Doug
Doug 2015년 6월 2일
I'm not sure if I'm clear on the question, but is this what you have in mind?:
V(hour+Minute/60 >= 8.75)

카테고리

Help CenterFile Exchange에서 Matrices and Arrays에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by