How can i know what object created with imroi did i move

Lets say i create a bunch of rectangles usind the following way
for i = 1:2
h(i) = imrect(gca, compdata(i,:));
end
how can i know which one did i move so i can store its location into a 2x4 matrix where the first row will be saved for the first rectangle and so on.

Answers (1)

If this is related to your other question, then you moved all of them. You never answered my question from there about why you wanted to save all the intermediate boxes in the first place. Of what use is that?

5 Comments

sorry i thought it would send me a mail if anyone answered that. Anyway i want to save that data because i want to do some calculations, lets say compute the distance between the components each time i move them. Its not a project or something so dont excpect to make any sense out of it, i just like programming stuff, so my next step will be this, an interactive function.
Well if I remember correctly from your original thread, you'd move a handle of the rectangle (say by clicking the corner handle and dragging it around and then finally dropping it a final location) and you'd record all the intermediate locations - whenever MATLAB decided to send you an update on the current position of the rectangle. So now you have an original location, all the intermediate locations, and the final location. Tell me which of those do you consider to be the one(s) that you "moved."
I am not really sure. When i first thought of it i believed i would be able to create the rectangles with imroi, and then update my original variable with the rectangle's position width and length, and then recalculate the distance based on the new data, by adding an 'addNewPositionCallback', or by using a timer. Now if the update will be constant while i move the object or just once when i drop it is something that i planned to check later.
Well I can't see any reason at all to capture the intermediate rectangles. Let's say I grabbed a corner and scribbled around the screen for 2 minute, generating thousands of rectangle, before I finally dropped it at the final location and size I want. Why on earth would you care about all the thousands of earlier rectangles before I made up my mind on the final location?
If you put it like that, i can't disagree. But still that makes it no easier for me as i can't seem to be able to store those positions at the right place and the update it. It would be easier if i didnt used a for and i draw each rectangle by myslef. But i like it more with the for loop so i can add 3 or 10 rectangles etc.

This question is closed.

Products

Tags

Asked:

on 15 Jul 2012

Closed:

on 20 Aug 2021

Community Treasure Hunt

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

Start Hunting!