Tracking in interpolated grid data

3 次查看(过去 30 天)
Kyra Oomen
Kyra Oomen 2024-1-16
编辑: Hassaan 2024-1-16
Hi,
I made a code where i have made a meshgrid of Xq and Yq, let's call it the field. Now an object moves through that field that leaves a track. The track is a matrix, that extract the needed values depending on it's position from a database. To visualize the object moving and its track that it leaves, i use the interp2 function so it looks like this line below. X and Y are the values from the database meshgrid. This works fine, but now a second object is introduced. It needs to track the track that the first object leaves in the field. I use "dsearchn"to find the indexes, but my question is where do i need to find the indexes in to make sure it can track the objects track in the field?
I am sorry if this is a vague description, I cannot give away too much information. I hope someone can help!
C = interp2(X,Y,trackmatrix,Xq,Yq)

回答(1 个)

Hassaan
Hassaan 2024-1-16
编辑:Hassaan 2024-1-16
I can provide few steps and recommendations as per my understanding.
1. Determine the Position of the First Object
Since the first object leaves a track, its position at any given time must be known or calculable. This can be represented as coordinates in your meshgrid. If you're dynamically updating the position of the first object, you should have this information available.
2. Update the Track Matrix
The trackmatrix should be updated based on the movement of the first object. This matrix holds the information about where the first object has been, which is crucial for the second object to follow.
3. Using dsearchn for the Second Object
dsearchn is typically used to find the nearest point in a set of points. In your case, you'd use it to find the closest point on the first object's track for the second object to move towards.
Where to Use dsearchn:
  • On the Track Matrix: You should apply dsearchn on the trackmatrix or its equivalent representation in the coordinate space of your meshgrid. This would allow the second object to find the nearest point on the track left by the first object.
  • Consider Time Factor: If the track changes over time (i.e., the track is dynamic), ensure that dsearchn is used in a way that accounts for the time factor. The second object should ideally follow the track as it was when the first object passed, not as it is at the current moment (if there's a difference).
4. Moving the Second Object
Once you have the nearest point on the track, you can move the second object towards this point. The specifics of this movement will depend on the rules of motion you have established in your system (e.g., direct movement, gradual movement with a certain speed, etc.).
5. Visualization
If you're visualizing this movement, you'll need to update your visualization at each step or iteration to reflect the new positions of both objects and the current state of the track.
6. Continuous Update
Your code needs to continuously update these positions and the track matrix as both objects move. This will likely involve a loop or a series of iterative updates, depending on how your simulation or model is structured.
-----------------------------------------------------------------------------------------------------------------------------------------------------
If you find the solution helpful and it resolves your issue, it would be greatly appreciated if you could accept the answer. Also, leaving an upvote and a comment are also wonderful ways to provide feedback.
Professional Interests
  • Technical Services and Consulting
  • Embedded Systems | Firmware Developement | Simulations
  • Electrical and Electronics Engineering
It's important to note that the advice and code are based on limited information and meant for educational purposes. Users should verify and adapt the code to their specific needs, ensuring compatibility and adherence to ethical standards.
Feel free to contact me.
  1 个评论
Kyra Oomen
Kyra Oomen 2024-1-16
That isn't quite the answer I was looking for. Thank you for responding anyway!

请先登录,再进行评论。

类别

Help CenterFile Exchange 中查找有关 Graphics Performance 的更多信息

标签

产品


版本

R2023a

Community Treasure Hunt

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

Start Hunting!

Translated by