1

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?

1 Answer 1

2

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)
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.