Last Axes Display Image

1 次查看(过去 30 天)
nsbd
nsbd 2011-7-1
Hi very simple, but I can not :(
See here%%%%
"
function Axes
N.fh=figure('unit','pix',...
'Position',[400 300 300 300],...
'MenuBar','None',...
'Resize','off',...
'Name','Axes Find problem',...
'Numbertit','off');
N.img1 = axes('Parent',N.fh,...
'Unit','pix',...
'Position',[20 100 100 100]);
N.img2 = axes('Parent',N.fh,...
'Unit','pix',...
'Position',[180 100 100 100]);
N.Push(1) = uicontrol('style','push',...
'position',[45 220 50 30],...
'Stri','image 1',...
'backgr',[0.90 0.90 0.90],...
'Callback',{@Push_1,N});
N.Push(2) = uicontrol('style','push',...
'position',[205 220 50 30],...
'Stri','image 2',...
'backgr',[0.90 0.90 0.90],...
'Callback',{@Push_2,N});
set([N.img1,N.img2],'CreateFcn',{@Image_CreateFcn,N})
function Image_CreateFcn
function Push_1(varargin)
N.Damage1=imread('cat.jpg');
axes(N.img1) %%%%ERROR
imshow(N.Damage1);
function Push_2(varargin)
N.Damage1=imread('dog.jpg');
axes(N.img2) %%%%ERROR
imshow(N.Damage1);
"

采纳的回答

nsbd
nsbd 2011-7-7
  2 个评论
Jan
Jan 2011-7-7
@nsbd: Please post the text directly.
You do not get an error but a warning. Calling AXES at first takes 0.1 seconds longer. More efficient is "imshow(H.Image2, 'Parent', H.axe(2));".
nsbd
nsbd 2011-7-7
Thks. was finally :)
<http://imageshack.us/photo/my-images/810/anda.png>

请先登录,再进行评论。

更多回答(2 个)

Nathan Greco
Nathan Greco 2011-7-1
You have a scope issue. Try doing this instead (note the "end"s)
function Axes
N.fh=figure('unit','pix',...
'Position',[400 300 300 300],...
'MenuBar','None',...
'Resize','off',...
'Name','Axes Find problem',...
'Numbertit','off');
N.img1 = axes('Parent',N.fh,...
'Unit','pix',...
'Position',[20 100 100 100]);
N.img2 = axes('Parent',N.fh,...
'Unit','pix',...
'Position',[180 100 100 100]);
N.Push(1) = uicontrol('style','push',...
'position',[45 220 50 30],...
'Stri','image 1',...
'backgr',[0.90 0.90 0.90],...
'Callback',{@Push_1,N});
N.Push(2) = uicontrol('style','push',...
'position',[205 220 50 30],...
'Stri','image 2',...
'backgr',[0.90 0.90 0.90],...
'Callback',{@Push_2,N});
set([N.img1,N.img2],'CreateFcn',{@Image_CreateFcn,N})
function Image_CreateFcn
end
function Push_1(varargin)
N.Damage1=imread('cat.jpg');
axes(N.img1) %%%%ERROR
imshow(N.Damage1);
end
function Push_2(varargin)
N.Damage1=imread('dog.jpg');
axes(N.img2) %%%%ERROR
imshow(N.Damage1);
end
end
Your N structure was not able to be reached in all of the functions without passing it into the different functions. By containing everything within 1 main function, your N structure is accessible by all subfunctions (your callbacks).
  4 个评论
Jan
Jan 2011-7-7
@nsbd: Do not use "Axes" as name of a function. It is confusing, because "axes" is a built-in function already.
Please explain, why you do not "want" to use the Nathan's working solution.
nsbd
nsbd 2011-7-7
http://hotfile.com/dl/123382234/9f1d26c/nsbd.rar.html
M-File upload.
two axes, there are two push buttons.while pressing the buttons
I want image be out on its own axis.
axis now shows only the last created.
I hope you understand me.

请先登录,再进行评论。


Jan
Jan 2011-7-7
You've sent me an email with a link to this thread. I really do not like to get such emails.
If I find the time to read a question and I have an answer, I will post it. If I do not post an answer, I either do not have the time to read it, or I do not have an answer. In both cases reading and deleting your email is a waste of time for me.
Instead of annoying the contributors, it would be a much better strategy to include a question in your post. See: How to ask a question and How do I write a good question.
Please care about Nathan's answer.
  3 个评论
nsbd
nsbd 2011-7-7
Sorry.don't send a message now. Thank you anyway
Jan
Jan 2011-7-7
@nsbd: Ok.

请先登录,再进行评论。

类别

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