How to create new points in existing matlab figure and execute function

This is briefly my question: If I have an existing 2D simple matlab figure, I would like to create new points by clicking (or by double-clicking) to a certain point. In addition, I would like to execute a script, or function, or even a command every time I create a new point. I did search both on the web and here carefully but I had no luck...

Could you help please? Thanks in advance!


something I found-> you need the ButtonDown-Callback:

ax=axes;%you need the handle of the axes
%to give additional values to the callback-fcn use:
%if you dont want to give extra values:

next you have to define the function mytestcallback like that:

function mytestcallback(h,eventdata)
point = get(h,'currentpoint');

now, within this function you can do whatever you want, like executing another script...


what I tried:

function test_mouse


function mytestcallback(h,eventdata)
point = get(h,'currentpoint')

what I get, when clicking on the axes:

suprisingly, there is a matrix, like:

point =

3.0219    1.2500    1.0000
3.0219    1.2500   -1.0000

which contains the coordinates of x,y,z with a z=[1,-1]; I guess you can ignore that, if you just have 2d-data

Now, if you want to add new values, you have to get the line in the plot, get the data and update it. I would do something like:

1. get the handle of the line myline=findall(myax,'Type','line') % be careful, this will return all lines (if you have more then one)

2. get the data of the line:


3. manipulate the data: -> well this depends on what you want to do (insert, append...)


4. update data:


Need Your Help

Text in circle in circular motion

android textview circular

I'm trying to create a textview with a circular background such as shown in the image below. I have 6 other circles like this as well which come from user input.

outputting html in javascript

jquery html ajax

I have been upgrading legacy pages to load data with AJAX.

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.