MATLAB to write a simple Gui__gui

Source: Internet
Author: User

As a convenient and easy to use tool, MATLAB is often used to show the results of related projects.

This blog explains how to create a simple GUI


First, start Matlab, enter guide in the command Window



Select the Blank GUI in the pop-up window



In the window that pops up, the left side is the toolbar, which you can drag

On the right is the display interface

Describes the following three features for this secondary use:

1. Button buttons: Can trigger the Click event, and then the corresponding response

2. Editable text: Usually in the appropriate location for the content description

3.axes: can display the picture



Drag and drop, as shown in the following figure:




Modify text and button display captions to modify editable text, for example,

Left-click to edit Text,



Change the caption of the button and editable text as shown in the picture



Then the button event response edit, double-click the button, which is the selected picture in the above image



Click the icon shown in the above image to edit the event response.

The function pushbutton1_callback is found in the subsequent. m file.


Add the following below it

function Pushbutton1_callback (hobject, EventData, handles)
axis  off%% axis display
%%filename store open file name  Pathname Store path percent
% For example open F:\data\1.jpg
%%filename=1.jpg pathname=f:\data\
[filename pathname] =uigetfile ({' *.jpg '; ' *.bmp '; ' *.* '}, ' open picture ');
%-percent string splicing assembly path in the above example said at this time srt=f:\data\1.jpg
str=[pathname filename];
%% Open Image
Im=imread (str);
%% open Axes1 handle for axes1 operation
axes (handles.axes1);
Percent% in axes1 display image
imshow (IM);
path1= ' F:\result\ ';
Percent% in Axes2 display results Image results folder
%% When original image is F:\data\1.jpg percent
% This time axes2 will show F:\result\1.jpg
str1=[path1 FileName]
im1=imread (str1);
Axes (handles.axes2);
Imshow (IM1);

As shown in the figure



Then run the GUI



After execution, as shown in the figure



Click to select a picture to select the image can



Axes event editing like button editing

Double-click the CREATEFCN icon after axes



Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.