Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

I need to remove the top bar (with the minimise, restore, close options) from th

ID: 3604306 • Letter: I

Question

I need to remove the top bar (with the minimise, restore, close options) from this final figure shown in matlab. Some of the code I've been trying is shown below. Please can someone try this with an image and see if they can get rid of the top bar and all other toolbars ect. I need to display the images on a spacial light modulator in fullscreen with 1020 by 1080 resolution.

Example of code

clear all; close all;

tic

%import image

img = imread('test2.tif');

size(img) %check size

img(:,:,4)=[]; %delete transparency

%delete extra rows

img2 = imcrop(img,[0 5 1080 1019]);

%Convert to greyscale image

awesome = rgb2gray(img2);

imshow(awesome);

%create complimentory image

img3 = imcomplement(awesome);

%full screen size

imshow(img3)

FigurejFrame = get(handle(gcf),'JavaFrame');

FigurejFrame.setMaximized(true);

hFig = gcf;

hAx = gca;

% set the figure to full screen

set(hFig,'units','normalized','outerposition',[0 0 1 1]);

% set the axes to full screen

set(hAx,'Unit','normalized','Position',[0 0 1 1]);

% hide the toolbar

% to hide the title

set(hFig,'NumberTitle','off');

toc

ENG 11:02 PM O Type here to search US 10/29/2017

Explanation / Answer

In MATLAB 7.6 (R2008a), the Close button on the upper left corner of a figure window and the Close menu item in the Title bar menu in a GUI application can be disabled by implementing a custom CloseRequestFcn in your GUI. To edit this function, right click on the Figure window in design mode and under the Callback functions portion select the CloseRequestFcn to include this function in the corresponding program file.

function figure1_CloseRequestFcn(hObject, eventdata, handles)

% hObject    handle to figure1 (see GCBO)

% eventdata reserved - to be defined in a future version of MATLAB

% handles    structure with handles and user data (see GUIDATA)

% Hint: delete(hObject) closes the figure

delete(hObject);

commenting the following line will prevent the CloseRequestFcn from deleting the figure when a user clicks on the Close button or uses the Close menu item.

delete(hObject)

Please note that with the above setting you have to use the following command to forcefully close the window:

close force