how to find the index?

3 visualizaciones (últimos 30 días)
Lilya
Lilya el 5 de Nov. de 2020
Comentada: Lilya el 5 de Nov. de 2020
Hi all,
I am facing a trouble in extracting the indecies from the 3rd dimension of matrix using 'find' function.
for example : time is 251 * 28 * 20, where 20 is the time.
index = find(time>=datenum(2019,02,01)& time<=datenum(2019,02,07));
any help will be apprecited

Respuesta aceptada

Ameer Hamza
Ameer Hamza el 5 de Nov. de 2020
Editada: Ameer Hamza el 5 de Nov. de 2020
By default, find() return linear indexes. To convert them to the dimension subscripts, you ind2sub()
index = find(time>=datenum(2019,02,01)& time<=datenum(2019,02,07));
[r, c, p] = ind2sub(size(time), index)
'p' is location in 3rd dimension.
  5 comentarios
Ameer Hamza
Ameer Hamza el 5 de Nov. de 2020
I don't get empty output on running this code. The output on my system is attached.
Lilya
Lilya el 5 de Nov. de 2020
after checking with what I have, it is working!!
The problem is it was taking another set.
Thank you very much Ameer.

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Mathematics en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by