matlab gui #5

  • Follow


Hi,

I have a problem with accessing image in my simple GUI.
I have got two buttons:

button1: 
I load an image - works fine.

[filename, pathname] = uigetfile('*.jpg', 'Pick an M-file');
ImOriginal = fullfile(pathname, filename);
imshow(ImOriginal),

button2:
I want to work with the image. Doesn't work, in button2 Matlab doesn't know ImOriginal.

Please help,
I know it is something with handles, but I can't figure it out.

Thank you very very much,
stepan
0
Reply stepan 3/28/2011 8:16:01 PM


"stepan" <user@compgroups.net/> wrote in message 
news:rbednSVVZpAccQ3QnZ2dnUVZ_t2dnZ2d@giganews.com...
> Hi,
>
> I have a problem with accessing image in my simple GUI.
> I have got two buttons:
>
> button1:
> I load an image - works fine.
>
> [filename, pathname] = uigetfile('*.jpg', 'Pick an M-file');
> ImOriginal = fullfile(pathname, filename);
> imshow(ImOriginal),
>
> button2:
> I want to work with the image. Doesn't work, in button2 Matlab doesn't 
> know ImOriginal.

That's correct. The variable ImOriginal lives in the workspace of button1's 
callback function; when that function finishes executing, all variables that 
live in that workspace are destroyed.

> Please help,
> I know it is something with handles, but I can't figure it out.

If you're creating the GUI using GUIDE, refer to this section of the
documentation for a description of some of the techniques you can use to
share data among your callback functions.

http://www.mathworks.com/help/techdoc/creating_guis/f5-998197.html

If you're creating your GUI programmatically, the appropriate section of the
documentation is:

http://www.mathworks.com/help/techdoc/creating_guis/f13-998197.html

-- 
Steve Lord
slord@mathworks.com
To contact Technical Support use the Contact Us link on 
http://www.mathworks.com 

0
Reply Steven_Lord 3/28/2011 8:43:46 PM


1 Replies
485 Views

(page loaded in 0.026 seconds)

Similiar Articles:













7/26/2012 3:40:22 PM


Reply: