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 Center および File ExchangeGraphics Object Properties についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by