Last Axes Display Image

1 vue (au cours des 30 derniers jours)
nsbd
nsbd le 1 Juil 2011
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);
"

Réponse acceptée

nsbd
nsbd le 7 Juil 2011
  2 commentaires
Jan
Jan le 7 Juil 2011
@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 le 7 Juil 2011
Thks. was finally :)
<http://imageshack.us/photo/my-images/810/anda.png>

Connectez-vous pour commenter.

Plus de réponses (2)

Nathan Greco
Nathan Greco le 1 Juil 2011
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 commentaires
Jan
Jan le 7 Juil 2011
@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 le 7 Juil 2011
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.

Connectez-vous pour commenter.


Jan
Jan le 7 Juil 2011
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 commentaires
nsbd
nsbd le 7 Juil 2011
Sorry.don't send a message now. Thank you anyway
Jan
Jan le 7 Juil 2011
@nsbd: Ok.

Connectez-vous pour commenter.

Catégories

En savoir plus sur Specifying Target for Graphics Output dans Help Center et File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by