File Exchange Pick of the Week

October 16th, 2007

MATLAB Basics: Setting a background image for a GUI

I recently got a question in my inbox asking how to set the background image for a GUI. This is done by creating an axes in the GUI and putting an image in it. Any UICONTROLs that you put on the GUI will appear over the image.

See this video for the details:

Video Content

Find the files here.

Other videos have been gathered here:
http://blogs.mathworks.com/pick/category/video/

Other MATLAB Basics posts have been gathered here:
http://blogs.mathworks.com/pick/category/matlab-basics/

7 Responses to “MATLAB Basics: Setting a background image for a GUI”

  1. Craig Miller replied on :

    Nifty idea. Is there a way to do this without using imshow from the Image Processing Toolbox, with just ‘plain’ Matlab?

    Thanks,
    Craig

  2. Doug replied on :

    With a little work, IMAGE should do fine here also. It is just that IMSHOW, from the image processing toolbox, takes care of many book keeping type tasks for you so your image always looks great.

    Doug

  3. Vaibhav Bedia replied on :

    I am having some problems with the background image.Things work fine once but if i close MATLAB and start the GUI again the axes loses its TAG and hence the axes becomes invisible.I need to rename it manually everytime.Is there a way to solve this?

  4. xiaolan replied on :

    May i know how to put an image on a button? i don’t want any wordings on the button, i just want to have image on it.

    Thanks.

  5. Doug replied on :

    xiaolan,

    You can put an image in a button like this:

    a = uicontrol(’style’,'pushbutton’)
    set(a,’cdata’,rand(10,10,3))

    I set he cdata to a random RGB matrix, but you can use whatever you like.

    Doug

  6. tasha replied on :

    i really need help on my MATLAB GUI program. can anyone help me? please email me at intan_tassya@yahoo.com if you’re wiling to help me.

    i’ve create a simple GUI interface. im using MATLAB V.7.2.. but i don’t even know how to input the function . for example, total_area= area1+area2 when we press the ‘calculate’ button. can anyone show me 1 clear example on this matter, i need to complete my project within 1 week starting from today…i’ve read all your comments etc, but i couldnt understand it.. besides, im importing the jpeg image into the axes which i labelled as ‘pic1′…when i generate, the picture will be displayed, but when i click the ‘next’ button, and trying to go back to the previous interface, the image gone. i dont understand why…please somebody, i really need help on MATLAB GUI…please email me..thank you very much :(

  7. Doug replied on :

    Tasha,

    I would recommend this video:

    http://blogs.mathworks.com/pick/2008/05/13/accessing-data-from-one-widget-to-another-in-guide/

    It will show you how to get data from one uicontrol (like an editbox) and use it as input in the callback of another.

    I am sorry, but I am not too clear on your second question. Please contact support@mathworks.com with a more detailed question.

    Doug

Leave a Reply

Wrap code fragments inside <pre> tags, like this:

<pre class="code">
a = magic(3);
sum(a)
</pre>

If you have a "<" character in your code, either follow it with a space or replace it with "&lt;" (including the semicolon).


Bob, Brett & Jiro share their favorite user-contributed submissions from the File Exchange.

  • oleg: The author has implemented skewness, kurtosis and checks answering appropriately to the critic.
  • Ashok: how to store 10 or more random number in a loop a loop for i = 1:n mean(i) = input(’enter the mean value...
  • Ben: Doug, Thanks for the very helpful videos! Uitables seem like a convenient way to make a customized property...
  • oleg: Allstats has no checks, no comments and could also be improved (talking about prctile implementatio). Not to...
  • Todd: Additional information and a link to download free MATLAB and Simulink LEGO MINDSTORMS NXT code can be found at...
  • Doug: @Leo, Here is the “English version” of that code. “vec = []” makes an empty variable...
  • leo: Dear Doug I have a question in your code ‘October 9th, 2009 at 13:53′ vec = []; vec = [vec val]; I...
  • Shanker Keshavdas: You sir, are a gentleman and a scholar… No really, helped me out a lot. As to what is...
  • Quan Zheng: how can I get a copy of stepspecs.m?
  • Doug: @Lucy I think this is what you seek to move a line with the mouse in MATLAB. http://blogs.math...

These postings are the author's and don't necessarily represent the opinions of The MathWorks.