get title of subplot back

3 views (last 30 days)
Max Müller
Max Müller on 8 Aug 2014
Commented: Max Müller on 8 Aug 2014
hey Guys, I have 9subplots in 1 figure and I want to give the User of my program the possibility to click of one subplot and get the title back....
do u have any tips ?

Accepted Answer

Azzi Abdelmalek
Azzi Abdelmalek on 8 Aug 2014
close
x=repmat((1:10)',1,9);
y=rand(10,9);
for k=1:9
subplot(3,3,k);
plot(x(:,k),y(:,k));
title(sprintf('title%d',k))
end
%------The code-----------------------
h=flipud(findobj(gcf,'type','axes'))
%-----get title N°5----------------
n=5
g=get(h(n),'title');
title_5=get(g,'string')
  2 Comments
Max Müller
Max Müller on 8 Aug 2014
Thanks....but ur "n" isnt a variable, which gets its value by clicking on the plot....its a variable the user needs to type in manuel.

Sign in to comment.

More Answers (1)

Max Müller
Max Müller on 8 Aug 2014
Edited: Max Müller on 8 Aug 2014
function main
Plot = figure set(Plot,'name','Plot','Tag','Plot','numbertitle','off');
for i = 1:9
a = rand(1,1) * 100
b = rand(1,1) * 3
x = 1:100
y = x.^b +a
subplot(5,2,i)
plot(x,y)
title([num2str(i)])
end
Data = findobj('type','axes');
disp('ok1')
disp(Data)
set(Data,'buttondownfcn',@click)
disp('ok2')
function click (gcbo,evendata,handles)
disp(gca)

Community Treasure Hunt

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

Start Hunting!