Displaying series of images in an axes in a GUI

조회 수: 1 (최근 30일)
Krishna Kumar
Krishna Kumar 2011년 6월 22일
Hi all, I have a GUI which has a axes in it apart from other elements. The functions called in callbacks generate different figures, say 5 in number. I want to display them in the axes one by one,such that user can see the previous or next image by pushing two push buttons provided. What is the best way to do this. Thanks in advance.

채택된 답변

Paulo Silva
Paulo Silva 2011년 6월 22일
function testimg
figure
pbh = uicontrol(gcf,'Style','pushbutton','String','Next',...
'Position',[10 20 60 40],...
'callback',@newimg);
pbh1 = uicontrol(gcf,'Style','pushbutton','String','Previous',...
'Position',[10 50 60 40],...
'callback',@oldimg);
axes
text(0.2,0.5,'Press the buttons Next or Previous to see the images')
ImGN=1;
function newimg(obj,event)
showimg
ImGN=ImGN+1;
if ImGN>5
ImGN=1;
end
end
function oldimg(obj,event)
showimg
ImGN=ImGN-1;
if ImGN<1
ImGN=5;
end
end
function showimg(obj,event)
switch ImGN
case 1
spy
case 2
[X,Y,Z] = peaks(30);
surfc(X,Y,Z)
case 3
x = -2.9:0.2:2.9;
bar(x,exp(-x.*x),'r')
case 4
x = -2.9:0.2:2.9;
plot(x,sin(x))
case 5
t = 0:pi/50:10*pi;
plot3(sin(t),cos(t),t)
grid on
axis square
end
end
end
  댓글 수: 1
Krishna Kumar
Krishna Kumar 2011년 6월 23일
Thanks a lot Silva. Though this is not exactly what i want, I don't have any better option, so I would go by this. Thanks to all.

댓글을 달려면 로그인하십시오.

추가 답변 (2개)

Sean de Wolski
Sean de Wolski 2011년 6월 22일
Use the axes(H) command to set the current axis to your axis of choice
doc axes
  댓글 수: 5
Sean de Wolski
Sean de Wolski 2011년 6월 22일
Well if you already have the data then just cla (clear axis) and call plot again with the new data?
That seems to simple a solution, I don't think I'm understanding you correctly.
Krishna Kumar
Krishna Kumar 2011년 6월 23일
I suppose there isnt a better way. would go with Silva's suggestion.

댓글을 달려면 로그인하십시오.


Krishna Kumar
Krishna Kumar 2011년 6월 23일
I got what I wanted from this thread, courtesy 'ImageAnalyst'. The solution is simple and meats my needs.
Thanks all:)

카테고리

Help CenterFile Exchange에서 Specifying Target for Graphics Output에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by