get title of subplot back

4 visualizaciones (últimos 30 días)
Max Müller
Max Müller el 8 de Ag. de 2014
Comentada: Max Müller el 8 de Ag. de 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 ?

Respuesta aceptada

Azzi Abdelmalek
Azzi Abdelmalek el 8 de Ag. de 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 comentarios
Max Müller
Max Müller el 8 de Ag. de 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 el 8 de Ag. de 2014
Thanks

Iniciar sesión para comentar.

Más respuestas (1)

Max Müller
Max Müller el 8 de Ag. de 2014
Editada: Max Müller el 8 de Ag. de 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