Clear Filters
Clear Filters

Select specific points in a figure before continuing a for loop

2 views (last 30 days)
Here, I plot complex eigenvalues in the complex plane where the imaginary part is in ordinate and the real part in abscissa. This spectrum will evolve according to the input conditions I ask it. The 2 figures below have been captured at 2 different times. From one moment to the other, the eigenvalues will not be at the same position in my figure.
Rather than looking for a correspondence between each eigenvalue at each time (like the function matchpairs), I would like to work with only a part of its values to reduce the code execution time. For example, with the ones that have the largest imaginary parts (the ones that form a kind of spider's web). The complexity is that I don't know their position in my array, nor the exact number of values I am interested in and the location of the eigenvalues in the vector is not the same from one moment to the next.
So my question is: is it possible to select some eigenvalues on my figure before continuing my loop?
To go further, let's suppose a case (figure below) where my values are in the middle of my spectrum (circled in red), is it still possible to extract exclusively these values before continuing my loop?
I know that my request is complicated but if someone has an idea, I'll take it. Thanks in advance for your help !

Accepted Answer

Benjamin Thompson
Benjamin Thompson on 2 Mar 2022
There is ginput or rectangle if you are looking to click on the plot and get points or rectangle properties returned to use in selecting a subset of your data.
Benjamin Thompson
Benjamin Thompson on 2 Mar 2022
You have not posted any code to help guide the answer here. If your problem is getting fairly complicated you may want to use AppDesigner to build a GUI with a button that lets the user choose when to do this selection. Or if you know the user always wants the do this selection process, there may be no problem waiting in the loop for ginput to return, at least if only one time.

Sign in to comment.

More Answers (0)


Find more on Loops and Conditional Statements in Help Center and File Exchange




Community Treasure Hunt

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

Start Hunting!