Professional Documents
Culture Documents
Home
Listchecker
MATLAB
Contact
About
Why use a GUI in MATLAB? The main reason GUIs are used is because it makes things simple for the
end-users of the program. If GUIs were not used, people would have to work from the command line interface,
which can be extremely difficult and fustrating. Imagine if you had to input text commands to operate your web
browser (yes, your web browser is a GUI too!). It wouldn’t be very practical would it? In this tutorial, we will
create a simple GUI that will add together two numbers, displaying the answer in a designated text field.
This tutorial is written for those with little or no experience creating a MATLAB GUI (Graphical User Interface). Basic
knowledge of MATLAB is not required, but recommended. MATLAB version 2007a is used in writing this tutorial. Both
earlier versions and new versions should be compatible as well (as long as it isn’t too outdated). Lets get started!
1 of 69 10/26/2010 4:10 PM
MATLAB GUI Tutorial - For Beginners | blinkdagger http://blinkdagger.com/matlab/matlab-gui-graphical-user-interface-tutorial...
2. You should see the following screen appear. Choose the first option Blank GUI (Default).
3. You should now see the following screen (or something similar depending on what version of MATLAB you are using
and what the predesignated settings are):
4. Before adding components blindly, it is good to have a rough idea about how you want the graphical part of the GUI to
look like so that it’ll be easier to lay it out. Below is a sample of what the finished GUI might look like.
2 of 69 10/26/2010 4:10 PM
MATLAB GUI Tutorial - For Beginners | blinkdagger http://blinkdagger.com/matlab/matlab-gui-graphical-user-interface-tutorial...
Add in all these components to the GUI by clicking on the icon and placing it onto the grid. At this point, your GUI
should look similar to the figure below :
2. Next, its time to edit the properties of these components. Let’s start with the static text. Double click one of the Static
Text components. You should see the following table appear. It is called the Property Inspector and allows you to
modify the properties of a component.
3 of 69 10/26/2010 4:10 PM
MATLAB GUI Tutorial - For Beginners | blinkdagger http://blinkdagger.com/matlab/matlab-gui-graphical-user-interface-tutorial...
3. We’re interested in changing the String parameter. Go ahead and edit this text to +.
After modifying these properties, the component may not be fully visible on the GUI editor. This can be fixed if you
resize the component, i.e. use your mouse cursor and stretch the component to make it larger.
4. Now, do the same for the next Static Text component, but instead of changing the String parameter to +, change it to =.
5. For the third Static Text component, change the String parameter to whatever you want as the title to your GUI. I kept
it simple and named it MyAdderGUI. You can also experiment around with the different font options as well.
6. For the final Static Text component, we want to set the String Parameter to 0. In addition, we want to modify the Tag
parameter for this component. The Tag parameter is basically the variable name of this component. Let’s call it
answer_staticText. This component will be used to display our answer, as you have probably already have guessed.
4 of 69 10/26/2010 4:10 PM
MATLAB GUI Tutorial - For Beginners | blinkdagger http://blinkdagger.com/matlab/matlab-gui-graphical-user-interface-tutorial...
7. So now, you should have something that looks like the following:
1. Next, lets modify the Edit Text components. Double click on the first Edit Text component. We want to set the String
parameter to 0 and we also want to change the Tag parameter to input1_editText, as shown below. This component
will store the first of two numbers that will be added together.
2. For the second Edit Text component, set the String parameter to 0 BUT set the Tag parameter input2_editText. This
component will store the second of two numbers that will be added together.
3. Finally, we need to modify the pushbutton component. Change the String parameter to Add! and change the Tag
parameter to add_pushbutton. Pushing this button will display the sum of the two input numbers.
5 of 69 10/26/2010 4:10 PM
MATLAB GUI Tutorial - For Beginners | blinkdagger http://blinkdagger.com/matlab/matlab-gui-graphical-user-interface-tutorial...
Rearrange your components accordingly. You should have something like this when you are done:
5. Now, save your GUI under any file name you please. I chose to name mine myAdder. When you save this file,
MATLAB automatically generates two files: myAdder.fig and myAdder.m. The .fig file contains the graphics of your
interface. The .m file contains all the code for the GUI.
6 of 69 10/26/2010 4:10 PM
MATLAB GUI Tutorial - For Beginners | blinkdagger http://blinkdagger.com/matlab/matlab-gui-graphical-user-interface-tutorial...
MATLAB automatically generates an .m file to go along with the figure that you just put together. The .m file is where we
attach the appropriate code to the callback of each component. For the purposes of this tutorial, we are primarily concerned
only with the callback functions. You don’t have to worry about any of the other function types.
1. Open up the .m file that was automatically generated when you saved your GUI. In the MATLAB editor, click on the
icon, which will bring up a list of the functions within the .m file. Select input1_editText_Callback.
This piece of code simply makes sure that the input is well defined. We don’t want the user to put in inputs that aren’t
numbers! The last line of code tells the gui to update the handles structure after the callback is complete. The handles
stores all the relevant data related to the GUI. This topic will be discussed in depth in a different tutorial. For now, you
should take it at face value that it’s a good idea to end each callback function with guidata(hObject, handles); so
that the handles are always updated after each callback. This can save you from potential headaches later on.
4. Now we need to edit the add_pushbutton_Callback. Click on the icon and select add_pushbutton_Callback. The
following code block is what you should see in the .m file.
% --- Executes on button press in add_pushbutton.
function add_pushbutton_Callback(hObject, eventdata, handles)
% hObject handle to add_pushbutton (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
7 of 69 10/26/2010 4:10 PM
MATLAB GUI Tutorial - For Beginners | blinkdagger http://blinkdagger.com/matlab/matlab-gui-graphical-user-interface-tutorial...
The two lines of code above take the strings within the Edit Text components, and stores them into the variables a and
b. Since they are variables of String type, and not Number type, we cannot simply add them together. Thus, we must
convert a and b to Number type before MATLAB can add them together.
6. We can convert variables of String type to Number type using the MATLAB command str2num(String argument).
Similarly, we can do the opposite using num2str(Number argument). The following line of code is used to add the
two inputs together.
total= (str2num(a) + str2num(b));
The next line of code converts the sum variable to String type and stores it into the variable c.
c = num2str(total);
The reason we convert the final answer back into String type is because the Static Text component does not display
variables of Number type. If you did not convert it back into a String type, the GUI would run into an error when it
tries to display the answer.
7. Now we just need to send the sum of the two inputs to the answer box that we created. This is done using the following
line of code. This line of code populates the Static Text component with the variable c.
set(handles.answer_staticText,'String',c);
The last line of code updates the handles structures as was previously mentioned.
guidata(hObject, handles);
Congratulations, we’re finished coding the GUI. Don’t forget to save your m-file. It is now time to launch the GUI!
8. If you don’t want MATLAB to automatically generate all those comments for each of the callbacks, there is a way to
disable this feature. From the GUI editor, go to File, then to Preferences.
8 of 69 10/26/2010 4:10 PM
MATLAB GUI Tutorial - For Beginners | blinkdagger http://blinkdagger.com/matlab/matlab-gui-graphical-user-interface-tutorial...
The first way is through the GUIDE editor. Simply press the icon on the GUIDE editor as shown in the figure
below:
The second method is to launch the GUI from the MATLAB command prompt. First, set the MATLAB current
directory to wherever you saved your .fig and .m file.
Next, type in the name of the GUI at the command prompt (you don’t need to type the .fig or .m extension):
9 of 69 10/26/2010 4:10 PM
MATLAB GUI Tutorial - For Beginners | blinkdagger http://blinkdagger.com/matlab/matlab-gui-graphical-user-interface-tutorial...
Try to input some numbers to test out the GUI. Congratulations on creating your first GUI!
So your GUI doesn’t work and you don’t know why. Here are a couple of tips that might help you find your bug:
1. If you can’t figure out where you error is, it might be a good idea to quickly go through this tutorial again.
2. The command line can give you many hints on where exactly the problem resides. If your GUI is not working for any
reason, the error will be outputted to the command prompt. The line number of the faulty code and a short description
of the error is given. This is always a good place to start investigating.
3. Make sure all your variable names are consistent in the code. In addition, make sure your component Tags are
consistent between the .fig and the .m file. For example, if you’re trying to extract the string from the Edit Text
component, make sure that your get statement uses the right tag! More specifically, if you have the following line in
your code, make sure that you named the Edit Text component accordingly!
a = get(handles.input1_editText,'String');
4. The source code is available here, and could be useful for debugging purposes.
5. If all else fails, leave a comment here and we’ll try our best to help.
10 of 69 10/26/2010 4:10 PM
MATLAB GUI Tutorial - For Beginners | blinkdagger http://blinkdagger.com/matlab/matlab-gui-graphical-user-interface-tutorial...
279 Responses to “MATLAB GUI (Graphical User Interface) Tutorial for Beginners”
Extremely useful. Can you add a further tutorial on how to plot data in a set of axes in the GUI?
You can find the tutorial on plotting data to a set of axes here.
First of all, I greatly appreciate these tutorials. I have found the Matlab documentation simply unreadable on the
subject of GUIs, and your approach with simple examples and easily modified code is perfect.
I was having some success with KeyPressFcn to make a graph with live keyboard input. Is there any way to integrate
this into a graph in a GUI? Or alternatively, have a GUI running simultaneously with a live figure responding to
KeyPressFcn?
Hello Fred,
I’m not sure if I’m understanding your question exactly, but I’ll try to answer it anyways.
If you look here, it’ll show you how to enter the command line mode so that you can modify any of the GUI’s
components in real time, including the axes.
But I think you may be asking something different. Are you asking if there is a way to press a particular key, say “e”,
and have it populate the axes on a GUI with a plot? I’d love to help, so if you can clarify your question, I will be in
better shape to answer!
Quan
Hi!,
First of all, myAdder GUI tutorial very useful for beginner like me. but I have a question, is it possible to send let say;
sine wave plot from one GUI window to another GUI window via UDP IP connection (using same computer)?
thanks,
zuri
11 of 69 10/26/2010 4:10 PM
MATLAB GUI Tutorial - For Beginners | blinkdagger http://blinkdagger.com/matlab/matlab-gui-graphical-user-interface-tutorial...
Hello Quan,
I’m having a problem similar to Fred’s here (I think). I am trying to create a GUI that displays an image, and a pointer
(little cross or whatever) to a current point (x,y). I want the cursor position to respond to key strokes (arrows), and
various shortcuts (say ‘Ctrl+F’ for toggling a filter, ‘r’ for refresh, etc.).
I know how to implement the movement of the cursor on the image, but don’t know how to trigger it with the
keystrokes.
Regards,
Gil
Zuri:
I’m a little confused on what you’re trying to accomplish, if you can elaborate then perhaps I might have an answer.
Gil:
I emailed you some code that I developed to explain this. I will probably turn this into a tutorial in the immediate
future
See also:
http://www.mathworks.com/matlabcentral/fileexchange/loadFile.do?objectId=12122&objectType=FILE
Diego
Would you please provide the pdf file of the tutorial so it can be printed?
Hello Vahid,
This is something that we are currently working on and hope to have available in the near future. But for now, we
don’t have this capability.
hello friends
i am ravi chaudhary . i done the project in fingerprint recognition in matlab. this gui tutorial help me to creating the
framework of my project. thank u very much.
if anybody help me for creating source code for my project .please contact us in my
email (ravikumar_l7i@rediffmail.com)or (ravikumar_l7@yahoo.co.in)
12 of 69 10/26/2010 4:10 PM
MATLAB GUI Tutorial - For Beginners | blinkdagger http://blinkdagger.com/matlab/matlab-gui-graphical-user-interface-tutorial...
thanks to teach a simple GUI but i wonderful to know how to make analysis of buried optical waveguide channel using
finite difference method using gui…
thanks for the feedback guys. if you click on the “matlab” tap at the top of the page, you will see a list of tutorials
Can you explain how we can create a button for browsing an image for doing further process.where will be this readed
image stored.whether this image can be seened.pls give the .m codes.
Thanks
Lukasz
Thanks a lot guys. This made it all much clearer than the guys from Mathworks.
Hi - I am very new to Matlab (7.0) and climbimg the steep learning curve. I contructed your Gui and works fine and I
think I understand the basic parts of your GUI code. I think it was nicely put together and very understandable.
1) Your first added code block, ‘input = str2num(get(hObject,’String’));’ shows the variable ‘input’ and ’str2num(get’
in blue type. My editor shows these in black type ?? I have looked at the preference settings but cannot change this -
but the code works and no errors. I think your screen shot more clearly defines the variable name by its blue color -
any ideas?
2) I am quite confused on the ‘handles’ versus ‘hObject’ - Am I right in thinking ‘handles’ are for data being sent
somewhere else and ‘hObject’ for data being received? - I am still trying to understand terminology and syntax.
Anyway - tks for you time - guys like you make it easier for guys like me!
Regards
13 of 69 10/26/2010 4:10 PM
MATLAB GUI Tutorial - For Beginners | blinkdagger http://blinkdagger.com/matlab/matlab-gui-graphical-user-interface-tutorial...
Hi Dave,
1) The coloring scheme is a little bit off due to the wordpress plugin that I use.
2) The handles structures contain’s all the information about all of the GUI’s objects. hObject on the other hand, is the
active object from which the callback is called.
So for example, if I pressed the “add” button, hObject in this case is the “add” button object.
Another example. When I input a number into the left edit text field, hObject is the edit text object.
There are a bunch of other tutorials that you can find on this website. I recommend taking a look at this one for a
better understanding:
http://www.blinkdagger.com/matlab/matlab-gui-tutorial-a-brief-introduction-to-handles
Quan, thanks you so much for your quick reply. I will continue with your tutorials as you suggest.
Dave
Hi my friend.
Nice work , and very thank’s to you disponibility to make this tutorials.
I spend a few hours to make some things that you have here in your site, now i can found and i can see that i’m a good
way.
But i have a little thing that i want to make better, so i have a edit text box where i write the 3 digits of a IP
address(0…255), so my ideia is to make a limit os 3 chars on this edit text box.
I used the KeyPressFcn to count a number of pressed keys and compare it to 0..9 if is backspace or delete e decraise
one number of this count.
After when i will read the data of all edit boxs i compare the text of the edit box with 0…255 and if is a letter os >255
o put ‘0′.
But also with this things isn’t perfect.
I search a lot in help of matlab, and also in internet, but i can’t found any info to make something like this.
Now how i have this i’m satisfied, but if i can make better i will more happy
So if you can give me any trick or any ideia, or any link to internet i will very appreciated.
Very tahnk’s to your pacience.
String regards,
Hugo
Hello Hugo,
I’m not quite sure how to do this off the top of my head. I’ll have to look into it. I’ll let you know if I find anything.
Quan
hello Hugo,
I could find this link very useful. The explanation was done in a very lucid manner. Thank you!
San
14 of 69 10/26/2010 4:10 PM
MATLAB GUI Tutorial - For Beginners | blinkdagger http://blinkdagger.com/matlab/matlab-gui-graphical-user-interface-tutorial...
help me…
i’ve tried the tutorial step-by-step but i got error. i still got error even i’ve rewrite and corrected the code twice. then i
tried to run the source code provided at this page and when i run it, still got the same error.now i’m really confuse.
here the error i got when i run the source code download from this page.
??? uiopen(’C:\Documents and Settings\F3\My Documents\ani’s fyp\MATLAB\GUI\MATLAB_GUI_Tutorial for
beginners(blinkdagger)-troubleshooting\myAdder.m’,1)
|
Error: Unexpected MATLAB expression.
>>
can u explain to me
meeb
15 of 69 10/26/2010 4:10 PM
MATLAB GUI Tutorial - For Beginners | blinkdagger http://blinkdagger.com/matlab/matlab-gui-graphical-user-interface-tutorial...
type:
myAdder
Thank you very much for the tutorial. From now on, I am ready to make GUI on matlab..
How to do that?
Regards
Pradipta,
http://www.blinkdagger.com/matlab/matlab-gui-tutorial-integrating-simulink-model-into-a-gui
good tutorial. I am trying to create a GUI which differentiates a function so input is going to be a function of time or
just a number, what will be code for converting string to function and how to use it. Pls help. The output will also be a
function or a number.
Thanks,
Regards
Suri
35. on 03 Apr 2008 at 10:58 pm 35innovate » Matlab GUI Tutorial - Disable Mouse Clicking
[...] with some experience creating a Matlab GUI. If you’re new to creating GUIs in Matlab, you should visit this
tutorial first. Basic knowledge of Matlab and an understanding on how data is shared among callbacks is highly [...]
Hi,
16 of 69 10/26/2010 4:10 PM
MATLAB GUI Tutorial - For Beginners | blinkdagger http://blinkdagger.com/matlab/matlab-gui-graphical-user-interface-tutorial...
my question is how do i get the user to view the array time, and from that select the range they require? (preferably in
listbox- so i can use for a gui plot)
e.g they would only require the data from the 5th row til the end. ( however they shouldn’t see the row no,but only the
date)
I have to cerat a GUI project for finding the resistance value from color code.Therefore we have 4 panels in which we
have to insert radio buttons.one block for finding resistance value & one for closing the window.So,suggest me
programme for it along with callback functions of radio buttons.
nice tutorial..may i ask that is there any way that can limit the length of numbers which user can input ?
may i know why i cant prevent user to key in other thing than number? I also cant open the source file downloaded? is
this because i using Matlab 6 rather than 7?
Nice. One of the first GUI tutorials I’ve seen that wasn’t too simple, or too advanced. A large amount of MATLAB
users don’t code with GUI’s because the process was never clearly explained to them. This tutuorial is simple and
CLEAR.
Jim,
Quan
Hi Quan,
Brilliant website, thanks very much.
If I was to create a clear pushbutton which resets the value displayed in the static text;what code would I write under
the pushbutton function?
thanks
17 of 69 10/26/2010 4:10 PM
MATLAB GUI Tutorial - For Beginners | blinkdagger http://blinkdagger.com/matlab/matlab-gui-graphical-user-interface-tutorial...
Jamal:
Does anyone know how I can make the editText so that when the user types, it automatically goes into the editText
box (i.e., the user doesn’t have to click in the box in order to type their input).
Thanks.
Hi. I’ve noticed that MATLAB truncates values when setting edit or static text boxes. Is there anyway of avoiding or
disabling this?
Thanks
thanks;)
Hi,
I have what is probably a very simple question but I just can’t find the answer:
How do I save my GUI as a jpeg so that I can use it in a report? (I’m working on a mac)
Thanks
Roisin
I have a problem to build up a simple GUI with a context graph y = a sin(x) where ‘a’ can be change by user with an
edit box …
However, there is an error when using str2num, the warning that is “Requires string or character array input”
even I copy the example in the above, the same error shown in using str2num.
Please help me to solve the problem … I am the beginner of using GUI, it suffers me a lot .
hi
i have following error in my gui code.please help me:
with regards
Vinay
18 of 69 10/26/2010 4:10 PM
MATLAB GUI Tutorial - For Beginners | blinkdagger http://blinkdagger.com/matlab/matlab-gui-graphical-user-interface-tutorial...
hi
thank u so much . it’s very useful.
Hi salute to you…No one make this much easier GUI MATLAB tutorial
They allow everyone to start developing GUIs very very fast while trying to understand what’s happening behind and
learn.
Thank you very much for this nice tutorial. I will be looking forward to see the following tutorials.
Hey, this may be a beginner question, but how do I call my GUI from a separate *.m file? Say I have file(a).m,
file(b).m, and file(b).fig. How do I call my file(b) GUI from file(a).m? I’ve tried a few ways, and they call the GUI
successfully, but none of the buttons or controls work. I get the following error:
Thanks.
Ben,
Make sure all the files above are located in the same directory. Give that a try!
Quan
Thanks, that worked. But, now what if I want the files to be in different directories?
Use the addpath command in the opening function of your main gui.
The addpath command will add a path to the list of MATLAB paths and enable you to run scripts/guis from a different
path other than the current matlab directory.
19 of 69 10/26/2010 4:10 PM
MATLAB GUI Tutorial - For Beginners | blinkdagger http://blinkdagger.com/matlab/matlab-gui-graphical-user-interface-tutorial...
Quan
Hi
love the tutorials. they’re great. i was wondering if you could help me. i want to read in an input from a mirochip using
a serial cable (DB9) and display that on the screen. Believe it or not, I have no idea how to read in the input, nor how
to set up the cable. but what i am most concerned with is how do I use a GUI to display an external input on the
screen????
This is the best tour for GUI I have ever seen. Thanks a lot!
please help me in my project it is a dtmf door lock system, you must first create a password and then you must login in
the keypad created using dtmf and enter your password correctly
please help me i need to pass this on or before tuesday please guys to those who are gifted with matlab skills…. thanks
please email me at lnvp_17@yahoo.com if youll help il refer you to my school mates Godbless
Hi ,
This tutorial is of great help for me , i did create my own GUI with 2 push buttons and two text fields which take input
for my second program
a)I want to run my 2nd matlab program with the input given in the text fields on mouse click on the push button
created.
Thanks in advance.
20 of 69 10/26/2010 4:10 PM
MATLAB GUI Tutorial - For Beginners | blinkdagger http://blinkdagger.com/matlab/matlab-gui-graphical-user-interface-tutorial...
if nargout
[varargout{1:nargout}] = gui_mainfcn(gui_State, varargin{:});
else
gui_mainfcn(gui_State, varargin{:});
end
% End initialization code - DO NOT EDIT
% --- Outputs from this function are returned to the command line.
function varargout = samplegui1_OutputFcn(hObject, eventdata, handles)
% varargout cell array for returning output args (see VARARGOUT);
% hObject handle to figure
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
21 of 69 10/26/2010 4:10 PM
MATLAB GUI Tutorial - For Beginners | blinkdagger http://blinkdagger.com/matlab/matlab-gui-graphical-user-interface-tutorial...
% --------------------------------------------------------------------
function Untitled_1_Callback(hObject, eventdata, handles)
% hObject handle to Untitled_1 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
It awful
This is indeed the best tutorial among all that I have found on the web so far. Thank you!
I have a question regarding a specific feature I would like my GUI to have. I would like to have a different set of
parameters for each of the items in the listbox. For example, if item 1 is selected, one set of parameters need to be
input by the user by the GUI, but if item 2 is selected, a different set of parameters will need to be input.
22 of 69 10/26/2010 4:10 PM
MATLAB GUI Tutorial - For Beginners | blinkdagger http://blinkdagger.com/matlab/matlab-gui-graphical-user-interface-tutorial...
thanks man…
very helpful
if we created this interface, how about the callback function we should write in? for examplee, the interface as u
shown above, what should we write at the callback(of add) button? so that when we pressing add, the numbers will be
adding together and displayed the outcomes at the ’static box’ . i’m using visual v.7.2 matlab
i’ve created the GUI as u shown above..but how to insert the function in? so that it will give us the final results?help
mee
if nargout
[varargout{1:nargout}] = gui_mainfcn(gui_State, varargin{:});
23 of 69 10/26/2010 4:10 PM
MATLAB GUI Tutorial - For Beginners | blinkdagger http://blinkdagger.com/matlab/matlab-gui-graphical-user-interface-tutorial...
else
gui_mainfcn(gui_State, varargin{:});
end
% End initialization code - DO NOT EDIT
24 of 69 10/26/2010 4:10 PM
MATLAB GUI Tutorial - For Beginners | blinkdagger http://blinkdagger.com/matlab/matlab-gui-graphical-user-interface-tutorial...
i’m using the source code(which i dload from u) and try to run in matlab GUI V.7.2… but it stated error.. may i know
why?
hi,
First of all thanks a lot for the tuorial.Found it rele help ful.
But I get the same error despite following the same steps.
The error goes like this:
hi!
thanks for the tutorial…its very useful and easy to learn (^^)v
thanks a lot to u
please i need to make a button called browse to load image in axis i have 2 axis one for original image and second after
applaying any filter i want to know as`uick how can ii do that
25 of 69 10/26/2010 4:10 PM
MATLAB GUI Tutorial - For Beginners | blinkdagger http://blinkdagger.com/matlab/matlab-gui-graphical-user-interface-tutorial...
i would like to ask help with my program. i would like to make a GUI that will add, subtract, multiply and divide 2
numbers. display the result of each operation done. hope you can help me…
i need to have the program….. thank you.. god bless
i want to make a program that will add, subtract, multiply and divide. i hope you can help me.. make the code
thank you
(this is just a part of a huge program)
tp20=0.015;
tu20=0.015
b=40;
a=20;
%%%%%%%%%Surface usinée%%%%%%%%%%%%%%%%%%%%%%%
alpha20u2 = 0 % alpha20u2 = alpha de la phase 20 de la surface usinée
beta20u2max = tu20/a
gamma20u2max = tu20/a
u20u2max = tu20/2
26 of 69 10/26/2010 4:10 PM
MATLAB GUI Tutorial - For Beginners | blinkdagger http://blinkdagger.com/matlab/matlab-gui-graphical-user-interface-tutorial...
v20u2 = 0
w20u2 = 0
% plot3(TTRS202(:,1),TTRS202(:,2),TTRS202(:,3),’k.’);
%
% xlabel(’bettaSU20′)
% ylabel(’gammaSU20′)
% Zlabel(’uSU20′)
% title(’écart de la surface usinée de la phase20′)
%
% C5 = convhulln(TTRS202);
% hold on
% for o = 1:size(C5,1)
% p = C5(o,[1 2 3 1]);
% patch(TTRS202(p,1),TTRS202(p,2),TTRS202(p,3),rand,’FaceAlpha’,0.4,’FaceColor’,'yel’,'edgecolor’,'gre’);
% end
%
% grid on
%%%%%%%%%%%%%%%%%%%%%%%%%Calcul vectoriel%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%Surface priamire%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%
%%%%%%%%%%%%%%%%%%%Surface secondaire%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
xA = 20;
yA = 10;
zA = 0;
xB = 0;
yB = 10;
zB = 10;
TP2M = cross(ROT2,AB)
27 of 69 10/26/2010 4:10 PM
MATLAB GUI Tutorial - For Beginners | blinkdagger http://blinkdagger.com/matlab/matlab-gui-graphical-user-interface-tutorial...
%%%%%% la surface ou du TTRS mis en jeux pour une pièce cubique et dont les
%%%%%% opérations sont de simples surfaçages.
Rx =1;
Ry =1;
Rz = 1;
x = 1;
y = 1;
z = 1;
alpha=1;
beta=1;
gamma=1;
u=1;
v=1;
w=1;
dir = x ; % dir = direction, dir dans le cas d’un plan est sa normale (”case à remplire”)
% SDT = [alpha beta gamma u v w]‘;
% TTRSposage = TTRS_PL : développement de SDT_PL (PL = plan) multiplication
% par la normale de la surface tolérancée
if dir == x
alpha = TTRSposage(1,1)*0 %(TTRSposage(i,j) = TTRSposage(ligne,colonne))
beta = TTRSposage(2,1)*1
gamma = TTRSposage(3,1)*1
u = TTRSposage(1,2)*1
v = TTRSposage(2,2)*0
w = TTRSposage(3,2)*0
TTRSpolyPosage = [alpha u; beta v; gamma w]
TTRSpolyPosageMatrice =[0 -TTRSposage(2,1) 0; 0 TTRSposage(2,1) 0; 0 0 -TTRSposage(3,1) ; 0 0
TTRSposage(3,1) ; -TTRSposage(1,2) 0 0; TTRSposage(1,2) 0 0]; %%%%%%%%%%%%POLYTOPE DE L
ERREUR DU MONTAGE %
else
if dir == y
alpha = TTRSposage(1,1)*1 %(TTRSposage(i,j) = TTRSposage(ligne,colonne))
beta = TTRSposage(2,1)*0
gamma = TTRSposage(3,1)*1
u = TTRSposage(1,2)*0
v = TTRSposage(2,2)*1
w = TTRSposage(3,2)*0
end
end
end
28 of 69 10/26/2010 4:10 PM
MATLAB GUI Tutorial - For Beginners | blinkdagger http://blinkdagger.com/matlab/matlab-gui-graphical-user-interface-tutorial...
plot3(TTRSpolyPosageMatrice(:,1),TTRSpolyPosageMatrice(:,2),TTRSpolyPosageMatrice(:,3),’k.’);
xlabel(’betta’)
ylabel(’gamma’)
Zlabel(’u')
title(’écart du système de posage de la phase20′)
C4 = convhulln(TTRSpolyPosageMatrice);
hold on
for n = 1:size(C4,1)
m = C4(n,[1 2 3 1]);
patch(TTRSpolyPosageMatrice(m,1),TTRSpolyPosageMatrice(m,2),TTRSpolyPosageMatrice(m,3),rand,’FaceAlpha’,0.4
end
grid on
% view([90 0])
D20 = TTRS202 +
[TTRSpolyPosageMatrice(q,:);TTRSpolyPosageMatrice(q,:);TTRSpolyPosageMatrice(q,:);TTRSpolyPosageMatrice(q,:);
DD20=[DD20;D20];
% plot3(D20(:,1),D20(:,2),D20(:,3),’g.’);
%
% xlabel(’betta20′)
% ylabel(’gamma20′)
% zlabel(’u20′)
% title(’somme des variations usinage + posage’)
%
C6 = convhulln(D20);
hold on
for k = 1:size(C6,1)
l = C6(k,[1 2 3 1]);
patch(D20(l,1),D20(l,2),D20(l,3),rand,’FaceAlpha’,0.8,’facecolor’,'red’);
end
end
grid on
Thank you for the wonderful tutorial. Keep up the great work (I am referring to the website and your actual work) !!!
29 of 69 10/26/2010 4:10 PM
MATLAB GUI Tutorial - For Beginners | blinkdagger http://blinkdagger.com/matlab/matlab-gui-graphical-user-interface-tutorial...
hi,
i want to combine three .m files into one .m file or can you teach me how to use GUI on this..
Instead of asking user to change some numbers in the m.file (the main program) before running the program, can we
use GUI command to change the numbers in the m.file while executing the file? (What syntax/code to be used to ask
user to input some numbers of certain parameter while running the program)
@ Jane: Have you try the tutorial out yourself? The requests you have seem very doable on your own after completing
the tutorial.
@ Karim: Put your giant code in the button call back, prior to the code use get( ) just as it was described in this tutorial
to get the values to be added. instead of two edit boxes, you need 3 edit boxes for your three parameters.
@ Melian: “pyramid’ from the pop-up menu, the pyramid model will be displayed. I don’t know how to set the handles
to do all of this”
I am gonna assume you just need help to display. All you have to do is in your menu callback put in
axes(’handles.name of your axes’). You can check the tag name in GUI builder and double click on the axes. Typically
it is ‘axes#’ or something of that sort. So you type in axes(handles.axes1)… this tell MATLAB to display whatever plot
function you use on that specific axis
@ Rosalina: The two values to be added in the edit boxes are user submitted. Just replace the button callback
(currently a+b) with your m.file, and you can change parameters on the fly. Use get( ) to get the values in the edit box.
And have them set to the variables in your m.file
I used this tutorial to create my first GUI and it was extremely useful, thankyou.
Everything works perfectly in my GUI after I type “GUIDE” in matlab, open the file, and press the green arrow to start
it. However if i try to open the GUI directly from the .fig file, it gives me a bunch of errors when i press the ‘calculate’
button.
30 of 69 10/26/2010 4:10 PM
MATLAB GUI Tutorial - For Beginners | blinkdagger http://blinkdagger.com/matlab/matlab-gui-graphical-user-interface-tutorial...
hi,
i need your help about my final year project.i have to do learning kit for control systems.for my first task i have to
complete time response which include in the syllabus.time response contains step response and impulse response.i
don’t know what is the coding for the transfer function.reply to my email asap.please help me…
if nargout
[varargout{1:nargout}] = gui_mainfcn(gui_State, varargin{:});
else
gui_mainfcn(gui_State, varargin{:});
end
% End initialization code - DO NOT EDIT
31 of 69 10/26/2010 4:10 PM
MATLAB GUI Tutorial - For Beginners | blinkdagger http://blinkdagger.com/matlab/matlab-gui-graphical-user-interface-tutorial...
% --- Outputs from this function are returned to the command line.
function varargout = time_response1_OutputFcn(hObject, eventdata, handles)
% varargout cell array for returning output args (see VARARGOUT);
% hObject handle to figure
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
%--------------------------------------------------------------------------
% --- Executes on button press in plot_pushbutton1.
function plot_pushbutton1_Callback(hObject, eventdata, handles)
% hObject handle to plot_pushbutton1 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
%--------------------------------------------------------------------------
% --- Executes on button press in reset_pushbutton2.
function reset_pushbutton2_Callback(hObject, eventdata, handles)
% hObject handle to reset_pushbutton2 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
handles.metricdata.a_input = 0;
32 of 69 10/26/2010 4:10 PM
MATLAB GUI Tutorial - For Beginners | blinkdagger http://blinkdagger.com/matlab/matlab-gui-graphical-user-interface-tutorial...
% --------------------------------------------------------------------
function menu_Callback(hObject, eventdata, handles)
% hObject handle to menu (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% --------------------------------------------------------------------
function open_Callback(hObject, eventdata, handles)
% hObject handle to open (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
file = uigetfile('*.fig');
if ~isequal(file, 0)
open(file);
end
% --------------------------------------------------------------------
function print_Callback(hObject, eventdata, handles)
% hObject handle to print (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
printdlg(handles.figure1)
% --------------------------------------------------------------------
function close_Callback(hObject, eventdata, handles)
% hObject handle to close (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
selection = questdlg(['Close ' get(handles.figure1,'Name') '?'],...
['Close ' get(handles.figure1,'Name') '...'],...
'Yes','No','Yes');
if strcmp(selection,'No')
return;
end
delete(handles.figure1)
I need to read few variables through GUI mode of MATLAB, store them and use them in other .m files which I have
already developed.
I went through your tutorials and found them very useful for GUI design purposes. I m having hard time in reading and
storing variables.
I have 5 variables to read so i hve 5 Static text and 5 edit text buttons.
I have added 1 push button which says enter and in the callback of ENTER i have added these lines:
output.data1=get(handles.data1,’string’) .
Could you please tell if this is right? and how can I store them? because I cant see the values which MATLAB reads in
command line or so.
hi sir..
thanks a lot for u r tutorial… its awesome.. only because of this i was able to complete Adding GUI to my project…
thanks….
33 of 69 10/26/2010 4:10 PM
MATLAB GUI Tutorial - For Beginners | blinkdagger http://blinkdagger.com/matlab/matlab-gui-graphical-user-interface-tutorial...
Sagar,
http://blinkdagger.com/matlab/matlab-gui-tutorial-a-brief-introduction-to-handles
If you use the keyboard/breakpoint command then you can see whats going on inside your GUI by exploring the local
workspace.
Quan
Hi!
Can anybody help me,how to move from one GUI to another GUI.Its like going from welcome screen gui to the
operational gui. by making use of push button.
thank you
@ Sebas
yes you can! There are multiple ways in getting an input. Edit text box, radio button, popup menu… you name it. All
you have to put in your pushbutton callback is to use the function get() on the objects you need information from. If
you go to our MATLAB > basic GUI pages there are many examples of how this is done!
@ Kuzya
We will when we get some time!
@ kartik
In your button callback put in the following
figurefilename(handles)
Thanks very much………… This tutorial helped me a lot by creating my first GUI file………………Thanks again
34 of 69 10/26/2010 4:10 PM
MATLAB GUI Tutorial - For Beginners | blinkdagger http://blinkdagger.com/matlab/matlab-gui-graphical-user-interface-tutorial...
>> Calc_DistanciaRadTierraVr1Test1
??? Undefined function or variable “designEval”.
My both files .fig and .m stay in the same archive, pls. help me.
i have a problem with my gui file.it dose only run with GUIDE BUILDER. give me a solutin for this.
hi! I am having a problem creating my project. How can i call an m-file which i have created in the editor using the gui.
for example, i have a button tagged bisection in my gui, what i want is when i press this button the m-file bisection will
execute. please help.. this is a project of mine in school.
hi
im trying to load values from edit box to matlab workspace, i was wondering if someone could help me with that.
thanks in advance.
thaaaaaaaaaaaaaaaaaaaaaaaaaaaaaanks
hi, what should i do if i want to input 2 texts, lets say a and b, and then process them in a separate m-file, lets say
process.m, and then display the result, lets say c, at the GUI?
Thanks for being so selfless and posting this knowledge on the web for everyone to access.
Naxus,
You shouldn’t have an issue calling the function ‘process.m’ in your GUI .m file as long as the inputs/outputs (aka
arguments) match up. In your GUI you would want to have something like this:
c = process(a,b);
disp(c) % or whatever display code you may want. Look into a static text box.
This requires process.m to be in the same folder as your GUI files, but if it’s not, you can use the addpath feature
which is talked about here:
35 of 69 10/26/2010 4:10 PM
MATLAB GUI Tutorial - For Beginners | blinkdagger http://blinkdagger.com/matlab/matlab-gui-graphical-user-interface-tutorial...
http://blinkdagger.com/?s=addpath#4
good luck,
Zane
Hey! Thanks for the tutorials on your site. They’re really helpful!
I got a problem with the edit text though. I was trying to check the string inside the edit field after every keystroke so i
used the KeypressFcn. The problem is that the ‘String’ value of the edit field isn’t updated after the keystroke but only
after the callback i think although the pressed key already shows up in the GUI itself.
Does anyone know how to force MATLAB to update the ‘String’ value or is there another value that actually
represents the string shown in the edit text?
thanks, Zane!
i’ll try doing that
this is a very good tutorial . thank u very much for this one.
hi
i have to use a check box to give the user the option to hold the graph that has been plotted by a push button, can
someone please help me how i can programm the check box? thanks in advance
Moe,
The these tutorials should be able to help you out with plotting the data:
http://blinkdagger.com/matlab/matlab-gui-tutorial-plotting-data-axes
% hold prevents the current axes from being overwritten when you plot a new graph
hold(handles.AxisName, ‘on’)
HTH,
Zane
36 of 69 10/26/2010 4:10 PM
MATLAB GUI Tutorial - For Beginners | blinkdagger http://blinkdagger.com/matlab/matlab-gui-graphical-user-interface-tutorial...
@ Offi,
I talked with Doug at MathWorks ( http://blogs.mathworks.com/videos/ ). The conclusion was that “unfortunately, the
change in the edit box string does not really register in MATLAB until you hit enter, or change focus in the GUI”.
So it won’t update after every keystroke. You might be able to embed ActiveX or Java controls if you really need this
to happen, but it’s outside of my abilities.
Good luck,
Zane
Thanks!
Hi again,
Is it possible to ’set’ the answer? Suppose I don’t want the answer to the a negative number. If the answer is going to
be negative, I want the static text of the answer to be automatically be 0. Do I use the code ‘if’?
Hey,
Hi
i have a situation that i have a GUI with some edit text box that each box views a parameter from the work space, the
task is to modify and replace the new parameter with the existing one in the work space. can someone please help me?
thanks very much in advance
hia
thanks for tutorial
can you show me a simple example of signal
i mean if we want to create sine wave how we do that
37 of 69 10/26/2010 4:10 PM
MATLAB GUI Tutorial - For Beginners | blinkdagger http://blinkdagger.com/matlab/matlab-gui-graphical-user-interface-tutorial...
I tried this demo, but It wouldnt work. I got this error message. Also, “get” and “num2str” didnt turn blue like shown.
Can you tell me whats wrong?
>> MyAdder
??? Error: File: MyAdder.m Line: 126 Column: 12
Expression or statement is incorrect–possibly unbalanced (, {, or [.
Anon,
Don’t worry about the coloring you see from the site, not everything matches up perfectly. It’s mainly just a visual aide
when explaining the code.
MATLAB is very specific about opening and closing brackets/parentheses/etc. Check out your line 126 (or post it
here) and make sure you’ve closed every bracket you open and don’t have any loose ones floating around.
Good luck
Zane
I also often get the window popup saying “File C:\…..\file.m is not found in the current directory or on the mathlab
path.” with the options to change dir, add to path or cancel/help.
In the file.m editor i can click on “Edit configurations for file.m” (its located under the green RUN arrow button, you
can reach it by clicking the small arrow down next to it)
In there i see a lot of files that are actually other projects and have nothing to do with this current file.
So I delete the others.
I cant find the configuration to actually seperate projects from each other and how to re-link m-file with the fig-file
thanks alot
The official MatLab GUIDE video does not explain the most important bit: callback functions at the backend.
This is in contrast is an excellent tutorial, thank you for your effort.
peace,
38 of 69 10/26/2010 4:10 PM
MATLAB GUI Tutorial - For Beginners | blinkdagger http://blinkdagger.com/matlab/matlab-gui-graphical-user-interface-tutorial...
Berkan
Hi
thank you for your wonderful site.
I have a problem
I can not save a variable inside my GUI
I use a GUI to get an equation for me and save it as a variable but it only prints the answer on Matlab command
window on push button press.
When i put my command on output function it dows not get any equation it shows zero only.
How can i use the output function?
Thanks a lot
waaaaaah………..
what a great innovation!!!!!!!!!!
u know saracasm….i guess
I have used three push buttons in my GUI now i want to use the output results of the two push buttons dat goes to a
static text box to be called in the third pushbutton call back as input;
how to do this?
these are really very good examples for people new on matlab gui. its possible to understand easily. thanks for all.
Dear sir,
Thank you very much for this simple and useful tutorial on GUI in matlab, expecting more tutorials like this.
hi
you can’t believe how much i was happy when i have run the first matlab GUI,
thank you for making the impossible (for me) possible.
i will study all the other tutorials
thanks
Thankyou brother
39 of 69 10/26/2010 4:10 PM
MATLAB GUI Tutorial - For Beginners | blinkdagger http://blinkdagger.com/matlab/matlab-gui-graphical-user-interface-tutorial...
139. on 03 Jun 2009 at 3:12 am 139Güncel ve Günlük Blog! | JunkChorn » Hocam Sesimi Duyuyor Musun? #3
[...] Ebrar denen şahsiyet ile hiç işim olmaz. Buyrun, ödevdeki butonlara görev atamayı anlatan çok güzel bir blog.
Bunun arkadan konuşmak olduğunu düşünüyor da olabilirsiniz, ama ben yargısız infaz [...]
What do I have to do differently to make the push button take the factorial of the variable? The tags and strings are a
bit confusing, not to mention the whole coding of the .m file afterward. An e-mail response would be greatly
appreciated.
Thanks
@ asder,
To get a grasp on the strings and tags, I recommend following each step in the tutorial and ask questions on specific
parts if they arise. To display the factorial of some input number, the main part you will want to edit is Step 4 of the
“Writing the Code for the GUI Callbacks” section. Find the section that looks similar to what I have below, but notice
the changes:
a = get(handles.input1_editText,'String');
b = get(handles.input2_editText,'String');
% a and b are variables of Strings type, and need to be converted
% to variables of Number type before they can be added together
Zane,
This is pretty much what I did, except I emitted b since I only have one edit text. It doesn’t seem to work, however. I
get something similar to 175.001 as the answer regardless of what I put in. Here is a screenshot of what I have. The
strings and tags are the same, save for the push button which is tagged “factorize_pushbutton1″
http://img188.imageshack.us/img188/2361/54570432.png
Thank you.
Dear friends,
I went through the mail chain.I am a student(masters), i want to take input form a hardware device(particularly
ultrasound probe) in real time and plot the input data in real time.
40 of 69 10/26/2010 4:10 PM
MATLAB GUI Tutorial - For Beginners | blinkdagger http://blinkdagger.com/matlab/matlab-gui-graphical-user-interface-tutorial...
since i am new to matlab, some matlab experts out here can help me.
I dont have any idea if this can be done in matlab or not, but i request if some body know it to help me to do this.
Regards,
DIleep.
email id:dil639@yahoo.com
Dear friends,
I went through the mail chain.I am a student(masters), i want to take input form a hardware device(particularly
ultrasound probe) in real time and plot the input data in real time.
since i am new to matlab, some matlab experts out here can help me.
I dont have any idea if this can be done in matlab or not, but i request if some body know it to help me to do this.
Regards,
DIleep.
email id:dil639@yahoo.com
Error in ==>
guidemfile>@(hObject,eventdata)MAGUI(’add_pushbutton_Callback’,hObject,eventdata,guidata(hObject))
41 of 69 10/26/2010 4:10 PM
MATLAB GUI Tutorial - For Beginners | blinkdagger http://blinkdagger.com/matlab/matlab-gui-graphical-user-interface-tutorial...
Error in ==>
guidemfile>@(hObject,eventdata)MAGUI(’add_pushbutton_Callback’,hObject,eventdata,guidata(hObject))
Hi Quan,
I’m a senior in college, and I needed a job during the summer. I just started working about a month ago. My boss
wanted me to GUIs with MATLAB (as well as other MATLAB related tasks). My MATLAB skills aren’t the greatest,
and I didn’t know MATLAB could make GUIs before then. I was too scared to tell my boss that I’m useless. So
naturally, I turned to the internet for help.
I’m so glad I found your site! I’ve read all of your GUI posts and almost every other blinkdagger post (you guys just
make it interesting). Thank you! My job is safe because of blinkdagger (Quan in particular)!
Again, you guys do amazing work and you’ve really helped me out! I’m suprised that I’m actually excited about
MATLAB now. Thanks!
Thanks again,
Joe
this code great help to me.. i run add program.. how to clear text field
how to make a GUI when i click the pushbutton on “start” it can control the scanner interface.means when i click a
buton in GUI, scanner interface will comeout..how to make it happen?
Hi there….
Excellent tutorial….really help me a lot… but i’ve got one question and need your favour/help….
how to open a .txt file and display it on the static text….for example let say readme.txt file which consist of numbers
and words/text…
42 of 69 10/26/2010 4:10 PM
MATLAB GUI Tutorial - For Beginners | blinkdagger http://blinkdagger.com/matlab/matlab-gui-graphical-user-interface-tutorial...
Thanks
Hi,
i like your myadder gui, but i want it so as the user types in the inputs it automatically updates the answer box without
using a pushbutton. Is that possible?
Thanks
Astromoof,
It is not possible to have the inputs update while you’re typing, but you can type in an input and then either: click away
from the box, or hit ‘enter’ and have them update. To do this, just put the code for you pushbuttoncallback into the
callback function for the edit text box.
Good luck!
-Zane
hai
thanks for ur model.
if we want take some text as input and the value of text is declared in workspace
how?
Hi?
I made one interface in Matlab. that is running now. But I wanna to rearrange that GUI. So that I want to know “How
to apply TAB strip in Marlab? ”
Is there anyone help me?
hai
thanks for ur model.
if we want take some text as input and the value of text is declared in workspace
how?
Hi,
i’m an italian student, and i’m trying to make a GUI, but i’ve a problem. When I use ‘global’ in a function to call a
variable defined in an other GUI function, matlab draws attention with an error. If I define the variable in the first
function, so without use global, matlab doesn’t give me any errors!!
For examples,
global intermedio;
I=im2double(intermedio);
where the variable ‘intermedio’ is defined above, in another GUI function. Matlab gives me an error. But if i define
‘intermedio’ in this function, i haven’t bugs!
Is there anyone help me?..thank u all, and sorry for my bad english!
43 of 69 10/26/2010 4:10 PM
MATLAB GUI Tutorial - For Beginners | blinkdagger http://blinkdagger.com/matlab/matlab-gui-graphical-user-interface-tutorial...
Excellent tut
Thanx for the effort!
hi
this website is very very useful.thank you very much.
Thanks
it’s possible to use GUI to create a moving point or something like a 2D randon walker? Many thanks
Please can someone asnwer me?..it’s possible to use GUI to create a moving point or something like a 2D randon
walker? Many thanks
mirza gango hy
Error in ==>
guidemfile>@(hObject,eventdata)GUIMagnetfalt('calc_button_Callback',hObject,eventdata,guidata(
I try to add the numbers, however Matlab complains that input should be done in an array. What may be the problem?
Is num supposed to be in an array? What type (e.g. num, double, int or char) should I use if I just want to convert input
44 of 69 10/26/2010 4:10 PM
MATLAB GUI Tutorial - For Beginners | blinkdagger http://blinkdagger.com/matlab/matlab-gui-graphical-user-interface-tutorial...
————————
[a direc] = dos(’dir Target_Detection.m’); % Obtain the directory listing of the file on the operating system
newlines = find(double(direc) == 10); % Check for newline characters in the returned string
dateloc = newlines(5)+1; % In DOS, the creation date for the file will show up at the fifth line of the output
OriginalFileDate = datenum(2009,09,26,12,13,0);
if (UserFiledate > OriginalFileDate) % Check if the createDate for the file is later that a specific time
disp(’Copied File’)
else
disp(’Original File’)
end
Thanks SO much for this website. As a newbie to MATLAB I was going nutty reading help files and the Mathworks
website. After reading your tutorials the mist has parted.
Please tell me, what code shall i include, if I want a close push button and perform a simple GUI close.
hi there…thanks 4 the perfect tutorial….it was a very easy-to-understand tutorial…;-) but i need some one who can
help me out in coming out with a loop like a for loop and all using MATLAB ….so if anyone can help me….pls do
kindly mail me at megal8725@hotmail.com…i dont mind paying u’ll….
thanks a lot
45 of 69 10/26/2010 4:10 PM
MATLAB GUI Tutorial - For Beginners | blinkdagger http://blinkdagger.com/matlab/matlab-gui-graphical-user-interface-tutorial...
thanks a lot dear….i actually knew nothing about creating GUI….but now i can make one
Hello everyone,
Thanx a lot!
Zox,
Your syntax of ‘2e-25′ should work as an input. Let us know if you get any errors using that or if you have a specific
usage question.
Hey ,
Great Tutorial
I was wondering if you could add to the “gcf” part of a designing a GUI.
Cheers
hi
May i know how to view a web cam inside the GUI interface?
Thanks
valerie
hi
Firstly thx for your tutorials. Really helpful for beginners like me.
keep it up.
the problem i’m facing is that i’m writting a program that enables a user to enter values into the gui like the start time
and stop and then click a button that will then plot either a sine wave or unit step function depending on the button
pressed.
I have tried to follow your tutorials and incoperate the different functionalities but it not working. below is piece of my
code, pliz help me figure out the problem.
thanks again.
46 of 69 10/26/2010 4:10 PM
MATLAB GUI Tutorial - For Beginners | blinkdagger http://blinkdagger.com/matlab/matlab-gui-graphical-user-interface-tutorial...
if nargout
[varargout{1:nargout}] = gui_mainfcn(gui_State, varargin{:});
else
gui_mainfcn(gui_State, varargin{:});
end
% End initialization code - DO NOT EDIT
% --- Outputs from this function are returned to the command line.
function varargout = untitled_OutputFcn(hObject, eventdata, handles)
% varargout cell array for returning output args (see VARARGOUT);
% hObject handle to figure
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
47 of 69 10/26/2010 4:10 PM
MATLAB GUI Tutorial - For Beginners | blinkdagger http://blinkdagger.com/matlab/matlab-gui-graphical-user-interface-tutorial...
48 of 69 10/26/2010 4:10 PM
MATLAB GUI Tutorial - For Beginners | blinkdagger http://blinkdagger.com/matlab/matlab-gui-graphical-user-interface-tutorial...
49 of 69 10/26/2010 4:10 PM
MATLAB GUI Tutorial - For Beginners | blinkdagger http://blinkdagger.com/matlab/matlab-gui-graphical-user-interface-tutorial...
hello sir
can u tell me
how can i do this
Sir i want to extract the RGB value of the part of the image selected by user
but
the gui contains many button and this image on single GUI(frame)
Having some serious trouble with this one - even using the source code directly invokes the same error:
50 of 69 10/26/2010 4:10 PM
MATLAB GUI Tutorial - For Beginners | blinkdagger http://blinkdagger.com/matlab/matlab-gui-graphical-user-interface-tutorial...
Neither this, nor another program I got working based off this that worked elsewhere, will run properly on the version
of MATLAB I’m using (7.5.0) - Any help would be VASTLY appreciated.
Hi S.M Negranol,
I’m gonna guess your issue is with the tag of you editText button. Double click your first editText button in the GUIDE
editor to bring up the property inspector.
You may need to check/fix your other buttons too, but make sure the tag property for all of your buttons match up
with the get(handles.buttonName) commands you’re using.
good luck,
Zane
helo sir..
am a newbie to matlab..
yesterday, i tried your tutorial step by step..
but, i got an error..
51 of 69 10/26/2010 4:10 PM
MATLAB GUI Tutorial - For Beginners | blinkdagger http://blinkdagger.com/matlab/matlab-gui-graphical-user-interface-tutorial...
help me please badly needed… how can i display the answer of my transfer function to my static text……
if nargout
[varargout{1:nargout}] = gui_mainfcn(gui_State, varargin{:});
else
gui_mainfcn(gui_State, varargin{:});
end
% End initialization code - DO NOT EDIT
52 of 69 10/26/2010 4:10 PM
MATLAB GUI Tutorial - For Beginners | blinkdagger http://blinkdagger.com/matlab/matlab-gui-graphical-user-interface-tutorial...
guidata(hObject, handles);
53 of 69 10/26/2010 4:10 PM
MATLAB GUI Tutorial - For Beginners | blinkdagger http://blinkdagger.com/matlab/matlab-gui-graphical-user-interface-tutorial...
guidata(hobject,handles)
a=str2num(get(handles.num,’String’));
b=str2num(get(handles.den,’String’));
sys=(tf(a,b))
set(handles.text3,’String’,sys)
Gr8
very helpful for the beginners
Fantastic tutorial!
sir currently i am trying to develop a graph manipulating application using matlab ,can you help me regarding this
project . please and thanks
54 of 69 10/26/2010 4:10 PM
MATLAB GUI Tutorial - For Beginners | blinkdagger http://blinkdagger.com/matlab/matlab-gui-graphical-user-interface-tutorial...
if nargout
[varargout{1:nargout}] = gui_mainfcn(gui_State, varargin{:});
else
gui_mainfcn(gui_State, varargin{:});
end
% End initialization code - DO NOT EDIT
% --- Outputs from this function are returned to the command line.
function varargout = demo1_OutputFcn(hObject, eventdata, handles)
% varargout cell array for returning output args (see VARARGOUT);
% hObject handle to
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
guidata(hObject,handles);
55 of 69 10/26/2010 4:10 PM
MATLAB GUI Tutorial - For Beginners | blinkdagger http://blinkdagger.com/matlab/matlab-gui-graphical-user-interface-tutorial...
If my input is sin(2*pi*50*t)
but program can’t read t
t=time
what should i do ?
Hello..
M designing DTMF encoder/decoder in matlab using GUI..
here i want a figure to be displayed by checking a push button press in someother callback function,, how to do it??
hello,
my final year project is based on image segmentation using fuzzy connectedness…can u plz guide me through
this….how can i include a image in matlab using GUI…
Hi,
Thanks a lot for such a nice and simple to understand GUI tutorial
Thanx Quan….
This was really helpful. I am personally in need to develop a GUI to be able to load an image and select coordinates on
it as well as to clear those selection by using a push button.
I would be grateful if you have any resources which can help me in this.
Thank you!
Mike.
Thanks for your tutorial! It’s very helpful and I finally laid out a GUI with buttons that work.
However, I was trying to make an adjustable horizontal line in a GUI plot. Is it possible? Any resources that I can look
56 of 69 10/26/2010 4:10 PM
MATLAB GUI Tutorial - For Beginners | blinkdagger http://blinkdagger.com/matlab/matlab-gui-graphical-user-interface-tutorial...
into?
Thanks,
Iris
how do i write the command if i need to instruct the user to insert values of an equation?
i have an assignment which need the input from the user but i don’t know how to begin….the values are needed to be
inserted into matrix and further algorithms will be carried out using the values inserted by the user….how do i do this?
if nargout
[varargout{1:nargout}] = gui_mainfcn(gui_State, varargin{:});
else
gui_mainfcn(gui_State, varargin{:});
end
% End initialization code - DO NOT EDIT
57 of 69 10/26/2010 4:10 PM
MATLAB GUI Tutorial - For Beginners | blinkdagger http://blinkdagger.com/matlab/matlab-gui-graphical-user-interface-tutorial...
58 of 69 10/26/2010 4:10 PM
MATLAB GUI Tutorial - For Beginners | blinkdagger http://blinkdagger.com/matlab/matlab-gui-graphical-user-interface-tutorial...
a = get(handles.input1_editText,’String’);
b = get(handles.input2_editText,’String’);
% a and b are variables of Strings type, and need to be converted
% to variables of Number type before they can be added together
I want to modify a gui.m file..my problem is..I have 3 m files of 3 equations. in these equations there are 2 unknown
variables.
from gui.fig i want to input these 2 unknown values by edit text and select an equation by pop-menu and get the result.
How can I manage gui.m file of this problem?? anyone please help me..
Hi,
I m really Thankfull 2 u for this nice and easily understandable tutorial.
59 of 69 10/26/2010 4:10 PM
MATLAB GUI Tutorial - For Beginners | blinkdagger http://blinkdagger.com/matlab/matlab-gui-graphical-user-interface-tutorial...
Thank you
supper
how to get read for a matrix form..eg: i want to read 2000 4000 in static text both at the same time..
hey can u help me i have a program in which i am reading no of frames using ‘mmreader’
and then after reading all frames
reading one particular frame as original and on converted to bW
now i want to insert my prog to GUI
but i dont know where excatlly i need to insert my matlab code in GUI (bcoz this is first time i am working with GUI)
as i want to load the image and then enter to no of frame i want to read
and save it
hey can u help me i have a program in which i am reading no of frames using ‘mmreader’
and then after reading all frames
reading one particular frame and convert it to bW
now i want to insert my prog to GUI
but i dont know where excatlly i need to insert my matlab code in GUI (bcoz this is first time i am working with GUI)
as i want to load the video and then enter to no of frame i want to read
and save it
plzz help me
I had a one problem. I just want to design a calculator same as TI-89 by using a MATLAB, but I didn’t know from
where should I look the information. Somebody told you shall have to look at tutorial, but I didn’t get nothing over
there. May be I am thinking that you can help me from figue out where the information I can find?
Hello dears
I have an assignment to load an image to the Matlab GUI and 4 letters around it (a letter at each side of the image).
Then in case a pushbotton is pressed, numbers are changed in random fashion. I wish to hear a clue in this with fully
60 of 69 10/26/2010 4:10 PM
MATLAB GUI Tutorial - For Beginners | blinkdagger http://blinkdagger.com/matlab/matlab-gui-graphical-user-interface-tutorial...
appreciation.
hiba
hello,
i need your help in my project ,actually i need a matlab program to simulate optical waveguide parameters.
hahahaha… wow, About 2 years ago I came to this site to learn how to use listchecker for dota…
Now in college I needed to find some Matlab help and HERE I Come to the same website.
Thanks blinkdagger, although in game one of my clan member actually has that name >_> and i doubt thats you
because he’s like a senior in high school lulz.
sir,
i facing a trouble by modifying your source code to use it for finding the z transform of a function that i enter into the
edit box ….can you please help me in this regards…..
here the source code that i made for it ..if u can identify the problem…
function varargout = ztrans(varargin)
% ZTRANS M-file for ztrans.fig
% ZTRANS, by itself, creates a new ZTRANS or raises the existing
% singleton*.
%
% H = ZTRANS returns the handle to a new ZTRANS or the handle to
% the existing singleton*.
%
% ZTRANS(’CALLBACK’,hObject,eventData,handles,…) calls the local
% function named CALLBACK in ZTRANS.M with the given input arguments.
%
% ZTRANS(’Property’,'Value’,…) creates a new ZTRANS or raises the
% existing singleton*. Starting from the left, property value pairs are
% applied to the GUI before ztrans_OpeningFcn gets called. An
% unrecognized property name or invalid value makes property application
% stop. All inputs are passed to ztrans_OpeningFcn via varargin.
%
% *See GUI Options on GUIDE’s Tools menu. Choose “GUI allows only one
% instance to run (singleton)”.
%
% See also: GUIDE, GUIDATA, GUIHANDLES
61 of 69 10/26/2010 4:10 PM
MATLAB GUI Tutorial - For Beginners | blinkdagger http://blinkdagger.com/matlab/matlab-gui-graphical-user-interface-tutorial...
‘gui_Callback’, []);
if nargin && ischar(varargin{1})
gui_State.gui_Callback = str2func(varargin{1});
end
if nargout
[varargout{1:nargout}] = gui_mainfcn(gui_State, varargin{:});
else
gui_mainfcn(gui_State, varargin{:});
end
% End initialization code - DO NOT EDIT
62 of 69 10/26/2010 4:10 PM
MATLAB GUI Tutorial - For Beginners | blinkdagger http://blinkdagger.com/matlab/matlab-gui-graphical-user-interface-tutorial...
total = ztrans(a);
c = func2str(total);
% need to convert the answer back into String type to display it
set(handles.answer_staticText,’String’,c);
guidata(hObject, handles);
Pramod,
Click ‘Guide’ again and select the tab ‘Open Existing GUI’
Thanks Zane!
Sir,
i want to make a GUI for my project to make a preview of webcam and take a snapshot from the video coming.The
problem that i am facing is that the preview is not clear and the remaining functions are also not working
properly.Kindly help me in this regard.
Xaim.
nic demo
thnx man!
63 of 69 10/26/2010 4:10 PM
MATLAB GUI Tutorial - For Beginners | blinkdagger http://blinkdagger.com/matlab/matlab-gui-graphical-user-interface-tutorial...
What is the actual datatype to which the entered number is converted in str2num function?
Pramod,
Hello Quan,
dear sir
since i use matlab version 5.3.1, would you please create relevant GUI tutorial, because I think above mentioned
tutoraial is in latest version
thank you indeed
Hello!
First of all, I want to say that I really liked your tutorial; it helped me a lot.
But I want to ask something: how can I set a String of a Static Text with a value that comes from the USB entry?
My problem is to make a GUI to display 4 values (numbers) that comes from the USB into 4 Statics Text (and it needs
to refresh itself). Could you help me?
Thank you!
Beautiful
Sir plz help me. our project are gui calculator by different program for example bisectin, newton, fixed point, matrix
multiplication etc
Sir please help me
64 of 69 10/26/2010 4:10 PM
MATLAB GUI Tutorial - For Beginners | blinkdagger http://blinkdagger.com/matlab/matlab-gui-graphical-user-interface-tutorial...
Sir plz help me. our project are gui calculator by different program for example bisectin, newton, fixed point, matrix
multiplication etc
we submitted our project 3june 2010. kindly help us
Hello sir,
Nice one!
[...] MATLAB GUI Tutorial – For Beginners | blinkdagger (tags: work, matlab) Deixe um Comentário [...]
i have to make GUI for my webcam. GUI that recalls my image from C drive. can anyone please give me the coding
reply please on xtreme2610@hotmail.com
Hi, i get the following error When i run my function. PLEASE HELP ME! i will be grateful.
>> TestAutoCovarianceCPInt
65 of 69 10/26/2010 4:10 PM
MATLAB GUI Tutorial - For Beginners | blinkdagger http://blinkdagger.com/matlab/matlab-gui-graphical-user-interface-tutorial...
hi;
i have a question!
how can i open another fig file and run it when i use callback of a pushbutton?when i use winopen(’another file!’),it
just open the form and doesnt run this!what should i do?help me.
please send me an e-mail as soon as possible.
my e-mail:s.arami89@yahoo.com
Hey,
Im a Matlab beginner.As i type guide in the command window,i get the following error.
??? Error using ==> copyfile
‘attrib’ is not recognized as an internal or external command,
operable program or batch file.
very good.
brilliant !!
but i have a small doubt…
i tried the code
total=str2num(a) + str2num(b)
and i forgot to convert ‘total’ back to string type. but still, the program worked !
why??
hello sir…im a matlab beginner and just doing my final project about comparing fingerprint algorithm using matlab gui.
66 of 69 10/26/2010 4:10 PM
MATLAB GUI Tutorial - For Beginners | blinkdagger http://blinkdagger.com/matlab/matlab-gui-graphical-user-interface-tutorial...
Excellent workdone…I really appreciate it. Hope to get more tutorials over here
Awesome.
Can any one explain me about the linking of ANN file to frontend GUI of matlab
hi.thanks a lot for posting this good and simple example gui.thanks a lot.
273. on 30 Sep 2010 at 12:59 pm 273Matlab GUI for Engaged Learning | Freedom University Tutorial Videos
[...] Matlab GUI Interface Tutorial For Beginner form Blinkdagger.com. I used this one to create my first GUI. [...]
Really good tutorial for MATLAB fresher…..i am waiting for next tutorial sheeet…..thanks sir…….
HELP!
I’ve got some strange behavior of MATLAB.
In button callback function I input:
and if I run my GUI using green “play” button in GUIDE Editor everithing if fine. I see value of ‘b’ in ‘estym’, but if I
open my GUI directly from MATLAB command windows I see error:
??? Attempt to reference field of non-structure array.
I discovered, if is this error ‘handles’ is empty
hi. i m a beginner.
and so on.
thanks..
If I have two push buttons in GUIDE. I just want to write code in the first callback’s button and the second button I
want to call it from the first one. How can I do?
Thanks.
[...] 为了实现这一目标,我没有采用老哥建议的C#语言,而更加倾向于Matlab。虽然我曾经有过matlab编程经
历,但是Matlab GUI和我还是第一次亲密接触,经过学习发现,Matlab GUI的功能强大,有着所见即所得的开发
67 of 69 10/26/2010 4:10 PM
MATLAB GUI Tutorial - For Beginners | blinkdagger http://blinkdagger.com/matlab/matlab-gui-graphical-user-interface-tutorial...
This is the best tour for GUI I have ever seen. Thanks very very very much.
Leave a Reply
<pre lang="MATLAB">
</pre>
Name
Mail (hidden)
Website
68 of 69 10/26/2010 4:10 PM
MATLAB GUI Tutorial - For Beginners | blinkdagger http://blinkdagger.com/matlab/matlab-gui-graphical-user-interface-tutorial...
Ads by Google
Gui Design
MATLAB 7.1
Gui Development
Gui Programming
69 of 69 10/26/2010 4:10 PM