Monthly Archives: May 2014

Matlab: Setting an image as form background

Image as form background in Matlab

Well, this is something new for me — new easy techniques — so I should post it here incase I forgot where to look.

Got the tips from here:

So, supposed hat you want to make an image as the background image that span all over the form/figure. The first step is to edit the .m file that correspondent to your form/figure .fig.

Find your figure Opening function, it should look like this:

function halaman_utama_OpeningFcn(hObject, eventdata, handles, varargin)

Now, exactly before guidata(hObject, handles); code, you put these codes:

% create an axes that spans the whole gui
ah = axes('unit', 'normalized', 'position', [0 0 1 1]);
% import the background image and show it on the axes
bg = imread('the_background.jpg'); imagesc(bg);
% prevent plotting over the background and turn the axis off
% making sure the background is behind all the other uicontrols
uistack(ah, 'bottom');

Those codes will show “the_background.jpg” located in the same directory as your GUI files as your form background and stay below other UI controls.