how to find the index?

5 次查看(过去 30 天)
Lilya
Lilya 2020-11-5
评论: Lilya 2020-11-5
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

采纳的回答

Ameer Hamza
Ameer Hamza 2020-11-5
编辑:Ameer Hamza 2020-11-5
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 个评论
Ameer Hamza
Ameer Hamza 2020-11-5
I don't get empty output on running this code. The output on my system is attached.
Lilya
Lilya 2020-11-5
after checking with what I have, it is working!!
The problem is it was taking another set.
Thank you very much Ameer.

请先登录,再进行评论。

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Matrix Indexing 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by