0

I am creating multiple handles for points taken from ginput(n) where n is no. of points to be taken. n is input from user.I want to create handles for all points and pass them using array to another function. SO code looks like this:

n=input('Enter no. of points  ');
[t]=ginput(n);
//I want to create handles for all points in t. 

function DrawBezier(//pass handles to this function )

I think one idea is to create an array and put handles in that. Now pass that array.

Nikhil Chilwant
  • 629
  • 3
  • 11
  • 31
  • Did you try your idea? Passing the handles in an array is just about the only sensible option I think. And there's nothing wrong with it... – sebastian Oct 31 '13 at 07:51

1 Answers1

1

ginput doesn't return a handle, but the cooordinates of the points clicked, so you can do something like:

[x,y] = ginput(n); % x and y are n x 1 arrays

function DrawBezier(x,y)
am304
  • 13,758
  • 2
  • 22
  • 40
  • I will use impoint() after ginput(). impoint will create handles. – Nikhil Chilwant Oct 30 '13 at 16:07
  • 1
    You should have said so in your original question. Once you have the coordinates `x` and `y`, you can create the handle using `h = impoint(gca,x, y)`. If you have multiple points, you can create an array of `x` and `y` coordinates, as well as an array of handles, and pass these arrays to your function as arguments. – am304 Nov 04 '13 at 09:13