Produce plot by clicking point in a current plot

Hi there,
I am currently trying to write a code which runs a function through two loops for example:
x = [1:10];
y_mtx=zeros(10);
for ii = 1:10
for jj = 1:10
y_mtx(ii,jj)=x(ii)*jj;
end
end
figure(1)
plot(x,y_mtx,'b*-')
hold on, grid on
This produces a plot with 10 lines, each connected by 10 points. And for each point there is a unique ii,jj value which has been used in the calculation. So for example if you were to click on the first point on the third line up, ii = 3, jj = 1. My desire is that when the user clicks a particular point in this plot, it uses these ii and jj values to plot the following:
% these values taken as example of the first point on the third line being clicked
ii = 3;
jj = 1;
x_2 = linspace(0.5*x(ii),1.5*x(ii),10);
y_2 = linspace(0.5*y_mtx(jj),1.5*y_mtx(jj),10);
z = x_2'*y_2.^2;
figure(2)
plot(x_2,z,'r-')
hold on, grid on
Ideally, I would essentially like to store the plot within the point and only reveal it when the point is clicked, but I don't know whether that is possible. Does anyone have any ideas?
Many thanks,
Nick

回答(0 个)

类别

帮助中心File Exchange 中查找有关 Annotations 的更多信息

产品

提问:

2013-2-7

Community Treasure Hunt

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

Start Hunting!

Translated by