get title of subplot back

3 Ansichten (letzte 30 Tage)
Max Müller
Max Müller am 8 Aug. 2014
Kommentiert: Max Müller am 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 ?

Akzeptierte Antwort

Azzi Abdelmalek
Azzi Abdelmalek am 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 Kommentare
Max Müller
Max Müller am 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.
Max Müller
Max Müller am 8 Aug. 2014
Thanks

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (1)

Max Müller
Max Müller am 8 Aug. 2014
Bearbeitet: Max Müller am 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!

Translated by