I asked this question last time. Answers there were very helpful. I want to suggest a slight variant. I need to access that element of a struct
array which has a(i).x==5.65 && a(i).y==32.23
?
Again i can run the good old for
loop and find the index of required element but i have to make such queries multiple time. What is the fastest data structure to do this? What method should i use to search through the struct
array to find the desired element?
You can use dot indexing to yield a comma-separated list and then coerce that into an array. You can then perform logical operations on the resulting array to yield a logical
array that you can use to then index into your struct
array
b = a([a.x] == 5 & [a.y] == 32)