From: Jon on
I am trying to plot 2 lines over an image and the x coordinates of
the image and the lines need to be correlated.

for example:

im=rand(50);
im_x=linspace(0,10,50);
im_y=linspace(0,100,50);

x=linspace(1,10,100);
y1=5*cos(x)+5;
y2=5*sin(x)+5;

creates a 50x50 image and 2 lines with 100 points each, but the x
values for the image have the same range as the x values for the
lines.

Essentially what I am trying to do is plot the image into 1 axis and
the 2 lines into a second axis, but I am unable to do this.

I am creating a plot with 2 sets of axes using the plotyy command,
then plotting the image into the first axis using imagesc, and then
plotting the 2nd line into the 2nd axis, but I get an error.

[ax,h1,h2]=plotyy(im_x,im_y,x,y1);
hold on
imagesc(im_x,im_y,im);
plot(ax(2),x,y2)

returns error:
??? Error using ==> plot
Parent destroyed during line creation

I have tried using the axes command on a fresh figure to create 2
axes rather than the plotyy command, but haven't had much success.

Any help would be appreciated