Intersect 2 arrays to find a position

1 visualización (últimos 30 días)
Inês Mendes
Inês Mendes el 2 de Jun. de 2015
Comentada: Inês Mendes el 2 de Jun. de 2015
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

Respuesta aceptada

Azzi Abdelmalek
Azzi Abdelmalek el 2 de Jun. de 2015
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 comentarios
Jan
Jan el 2 de Jun. de 2015
A simplification:
ii = sscanf(s, '%d.%d')
Inês Mendes
Inês Mendes el 2 de Jun. de 2015
Thank you Azzi and Jan! You helped a lot :)

Iniciar sesión para comentar.

Más respuestas (1)

Doug
Doug el 2 de Jun. de 2015
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)

Community Treasure Hunt

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

Start Hunting!

Translated by