Professional Documents
Culture Documents
1 de 89
http://blinkdagger.com/matlab/matlab-gui-graphical-user-interface-tutorial-for-beginners/
blinkdagger
an Engineering and MATLAB blog
Home
Listchecker
MATLAB
Contact
About
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 isnt too outdated). Lets get started!
17/03/2010 22:13
2 de 89
http://blinkdagger.com/matlab/matlab-gui-graphical-user-interface-tutorial-for-beginners/
Contents
Initializing GUIDE (GUI Creator)
Creating the Visual Aspect of the GUI: Part 1
Creating the Visual Aspect of the GUI: Part 2
Writing the Code for the GUI Callbacks
Launching the GUI
Troubleshooting and Potential Problems
Related Posts and Other Links
2. You should see the following screen appear. Choose the first option Blank GUI (Default).
17/03/2010 22:13
3 de 89
http://blinkdagger.com/matlab/matlab-gui-graphical-user-interface-tutorial-for-beginners/
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):
17/03/2010 22:13
4 de 89
http://blinkdagger.com/matlab/matlab-gui-graphical-user-interface-tutorial-for-beginners/
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 itll be easier
to lay it out. Below is a sample of what the finished GUI might look like.
17/03/2010 22:13
5 de 89
http://blinkdagger.com/matlab/matlab-gui-graphical-user-interface-tutorial-for-beginners/
2. Next, its time to edit the properties of these components. Lets 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.
17/03/2010 22:13
6 de 89
http://blinkdagger.com/matlab/matlab-gui-graphical-user-interface-tutorial-for-beginners/
3. Were interested in changing the String parameter. Go ahead and edit this text to +.
17/03/2010 22:13
7 de 89
http://blinkdagger.com/matlab/matlab-gui-graphical-user-interface-tutorial-for-beginners/
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. Lets call it answer_staticText. This component will be used to display our
answer, as you have probably already have guessed.
7. So now, you should have something that looks like the following:
17/03/2010 22:13
8 de 89
http://blinkdagger.com/matlab/matlab-gui-graphical-user-interface-tutorial-for-beginners/
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.
17/03/2010 22:13
9 de 89
http://blinkdagger.com/matlab/matlab-gui-graphical-user-interface-tutorial-for-beginners/
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.
Rearrange your components accordingly. You should have something like this when you are done:
17/03/2010 22:13
10 de 89
http://blinkdagger.com/matlab/matlab-gui-graphical-user-interface-tutorial-for-beginners/
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.
17/03/2010 22:13
11 de 89
http://blinkdagger.com/matlab/matlab-gui-graphical-user-interface-tutorial-for-beginners/
This piece of code simply makes sure that the input is well defined. We dont want the user to put in inputs that arent 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 its 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.
3. Add the same block of code to input2_editText_Callback.
4. Now we need to edit the add_pushbutton_Callback. Click on the
you should see in the .m file.
= get(handles.input1_editText,'String');
= 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
17/03/2010 22:13
12 de 89
http://blinkdagger.com/matlab/matlab-gui-graphical-user-interface-tutorial-for-beginners/
guidata(hObject, handles);
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 'umber type, we cannot simply add them together. Thus, we must convert a and b to 'umber type before MATLAB can add
them together.
6. We can convert variables of String type to 'umber 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 'umber 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, were finished coding the GUI. Dont forget to save your m-file. It is now time to launch the GUI!
8. If you dont 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.
17/03/2010 22:13
13 de 89
http://blinkdagger.com/matlab/matlab-gui-graphical-user-interface-tutorial-for-beginners/
17/03/2010 22:13
14 de 89
http://blinkdagger.com/matlab/matlab-gui-graphical-user-interface-tutorial-for-beginners/
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 dont need to type the .fig or .m extension):
17/03/2010 22:13
15 de 89
http://blinkdagger.com/matlab/matlab-gui-graphical-user-interface-tutorial-for-beginners/
Try to input some numbers to test out the GUI. Congratulations on creating your first GUI!
4. The source code is available here, and could be useful for debugging purposes.
5. If all else fails, leave a comment here and well try our best to help.
17/03/2010 22:13
16 de 89
http://blinkdagger.com/matlab/matlab-gui-graphical-user-interface-tutorial-for-beginners/
222 Responses to MATLAB GUI (Graphical User Interface) Tutorial for Beginners
1. on 20 'ov 2007 at 10:04 am 1Mike
Thanks for the tutorial - its nice and clear
2. on 28 'ov 2007 at 11:54 am 2Fred
Extremely useful. Can you add a further tutorial on how to plot data in a set of axes in the GUI?
3. on 28 'ov 2007 at 12:36 pm 3Quan Quach
You can find the tutorial on plotting data to a set of axes here.
You can find a list of matlab tutorials here.
4. on 28 'ov 2007 at 3:04 pm 4Fred
17/03/2010 22:13
17 de 89
http://blinkdagger.com/matlab/matlab-gui-graphical-user-interface-tutorial-for-beginners/
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?
5. on 28 'ov 2007 at 4:06 pm 5Quan Quach
Hello Fred,
Im not sure if Im understanding your question exactly, but Ill try to answer it anyways.
If you look here, itll show you how to enter the command line mode so that you can modify any of the GUIs 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? Id love to help, so if you can clarify your question, I will be in better shape to answer!
Quan
6. on 16 Dec 2007 at 8:32 pm 6zuri
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
7. on 17 Dec 2007 at 4:25 am 7Gil
Hello Quan,
Great tutorial, loved it!
Im having a problem similar to Freds 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 dont know how to trigger it with the keystrokes.
Regards,
Gil
17/03/2010 22:13
18 de 89
http://blinkdagger.com/matlab/matlab-gui-graphical-user-interface-tutorial-for-beginners/
17/03/2010 22:13
19 de 89
http://blinkdagger.com/matlab/matlab-gui-graphical-user-interface-tutorial-for-beginners/
17/03/2010 22:13
20 de 89
http://blinkdagger.com/matlab/matlab-gui-graphical-user-interface-tutorial-for-beginners/
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.
Two questions though:
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
22. on 17 Feb 2008 at 5:21 pm 22Quan Quach
Hi Dave,
1) The coloring scheme is a little bit off due to the wordpress plugin that I use.
2) The handles structures contains all the information about all of the GUIs 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
23. on 18 Feb 2008 at 1:32 am 23Dave Barr
Quan, thanks you so much for your quick reply. I will continue with your tutorials as you suggest.
Excellent and clear
work
Dave
24. on 25 Feb 2008 at 11:47 pm 24Hugo
17/03/2010 22:13
21 de 89
http://blinkdagger.com/matlab/matlab-gui-graphical-user-interface-tutorial-for-beginners/
Hi my friend.
Nice work , and very thanks 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 im 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(0255), 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 0255 and if is a letter os >255 o put 0.
But also with this things isnt perfect.
I search a lot in help of matlab, and also in internet, but i cant found any info to make something like this.
Now how i have this im 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 tahnks to your pacience.
String regards,
Hugo
25. on 26 Feb 2008 at 5:47 pm 25Quan Quach
Hello Hugo,
Im not quite sure how to do this off the top of my head. Ill have to look into it. Ill let you know if I find anything.
Quan
26. on 27 Feb 2008 at 6:08 am 26San
hello Hugo,
I could find this link very useful. The explanation was done in a very lucid manner. Thank you!
San
27. on 28 Feb 2008 at 8:55 pm 27izzy
how we do linear regression using GUI
how to display the equation or model??
help me
28. on 29 Feb 2008 at 10:03 pm 28meeeeebbbb
ive tried the tutorial step-by-step but i got error. i still got error even ive rewrite and corrected the code twice. then i tried to run the source code
17/03/2010 22:13
22 de 89
http://blinkdagger.com/matlab/matlab-gui-graphical-user-interface-tutorial-for-beginners/
provided at this page and when i run it, still got the same error.now im 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\anis fyp\MATLAB\GUI\MATLAB_GUI_Tutorial for
beginners(blinkdagger)-troubleshooting\myAdder.m,1)
|
Error: Unexpected MATLAB expression.
??? Attempt to reference field of non-structure array.
Error in ==> myAdder>add_pushbutton_Callback at 134
a = get(handles.input1_editText,String);
Error in ==> gui_mainfcn at 95
feval(varargin{:});
Error in ==> myAdder at 42
gui_mainfcn(gui_State, varargin{:});
??? Error using ==> myAdder(add_pushbutton_Callback,gcbo,[],guidata(gcbo))
Attempt to reference field of non-structure array.
??? Error while evaluating uicontrol Callback
??? Attempt to reference field of non-structure array.
Error in ==> myAdder>add_pushbutton_Callback at 134
a = get(handles.input1_editText,String);
Error in ==> gui_mainfcn at 95
feval(varargin{:});
Error in ==> myAdder at 42
gui_mainfcn(gui_State, varargin{:});
??? Error using ==> myAdder(add_pushbutton_Callback,gcbo,[],guidata(gcbo))
Attempt to reference field of non-structure array.
??? Error while evaluating uicontrol Callback
>>
can u explain to me
17/03/2010 22:13
23 de 89
http://blinkdagger.com/matlab/matlab-gui-graphical-user-interface-tutorial-for-beginners/
17/03/2010 22:13
24 de 89
http://blinkdagger.com/matlab/matlab-gui-graphical-user-interface-tutorial-for-beginners/
25 de 89
http://blinkdagger.com/matlab/matlab-gui-graphical-user-interface-tutorial-for-beginners/
buttons.
38. on 09 Apr 2008 at 9:45 pm 38knight
its nice n comprehensive
39. on 10 Apr 2008 at 1:01 am 39ckk
nice tutorial..may i ask that is there any way that can limit the length of numbers which user can input ?
40. on 11 Apr 2008 at 1:52 am 40andy
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?
41. on 11 Apr 2008 at 10:52 pm 41Jim
Nice. One of the first GUI tutorials Ive seen that wasnt too simple, or too advanced. A large amount of MATLAB users dont code with GUIs
because the process was never clearly explained to them. This tutuorial is simple and CLEAR.
42. on 12 Apr 2008 at 2:32 am 42Quan Quach
Jim,
Thanks for the positive feedback!!
Quan
43. on 17 Apr 2008 at 11:46 am 43harsha
great work sir.. now i got a hope of completing my project!!!
44. on 23 Apr 2008 at 9:45 am 44Jamal
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
45. on 23 Apr 2008 at 12:14 pm 45Daniel Sutoyo
Jamal:
17/03/2010 22:13
26 de 89
http://blinkdagger.com/matlab/matlab-gui-graphical-user-interface-tutorial-for-beginners/
17/03/2010 22:13
27 de 89
http://blinkdagger.com/matlab/matlab-gui-graphical-user-interface-tutorial-for-beginners/
Please help me to solve the problem I am the beginner of using GUI, it suffers me a lot .
52. on 27 Jun 2008 at 5:40 am 52vinay
hi
i have following error in my gui code.please help me:
??? Reference to non-existent field
with regards
Vinay
53. on 16 Jul 2008 at 1:43 am 53Temy
Thank you so much!!! Its very helpful ^-^
54. on 21 Jul 2008 at 2:56 pm 54Anonymous
danke meister fr die hilfe
thanks man for your help
55. on 03 Aug 2008 at 10:37 am 55akbar
hi
thank u so much . its very useful.
56. on 04 Aug 2008 at 9:58 pm 56C Babu
Hi salute to youNo one make this much easier GUI MATLAB tutorial
57. on 06 Aug 2008 at 5:32 am 57OnOffPT
Thank you for all your tutorials.
They allow everyone to start developing GUIs very very fast while trying to understand whats happening behind and learn.
58. on 18 Aug 2008 at 2:34 am 58'r
Thank you very much for this nice tutorial. I will be looking forward to see the following tutorials.
I hope other tutorials are also very easy to understand.
59. on 21 Aug 2008 at 11:08 pm 59Reju
17/03/2010 22:13
28 de 89
http://blinkdagger.com/matlab/matlab-gui-graphical-user-interface-tutorial-for-beginners/
17/03/2010 22:13
29 de 89
http://blinkdagger.com/matlab/matlab-gui-graphical-user-interface-tutorial-for-beginners/
17/03/2010 22:13
30 de 89
http://blinkdagger.com/matlab/matlab-gui-graphical-user-interface-tutorial-for-beginners/
%
instance to run (singleton)".
%
% See also: GUIDE, GUIDATA, GUIHANDLES
% Edit the above text to modify the response to help samplegui1
% Last Modified by GUIDE v2.5 12-Sep-2008 20:08:16
% Begin initialization code - DO NOT EDIT
gui_Singleton = 1;
gui_State = struct('gui_Name',
mfilename, ...
'gui_Singleton', gui_Singleton, ...
'gui_OpeningFcn', @samplegui1_OpeningFcn, ...
'gui_OutputFcn', @samplegui1_OutputFcn, ...
'gui_LayoutFcn', [] , ...
'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
% --- Executes just before samplegui1 is made visible.
function samplegui1_OpeningFcn(hObject, eventdata, handles, varargin)
% This function has no output args, see OutputFcn.
% hObject
handle to figure
% eventdata reserved - to be defined in a future version of MATLAB
% handles
structure with handles and user data (see GUIDATA)
% varargin
command line arguments to samplegui1 (see VARARGIN)
% Choose default command line output for samplegui1
handles.output = hObject;
% Update handles structure
guidata(hObject, handles);
% UIWAIT makes samplegui1 wait for user response (see UIRESUME)
% uiwait(handles.figure1);
% --- 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
17/03/2010 22:13
31 de 89
% handles
http://blinkdagger.com/matlab/matlab-gui-graphical-user-interface-tutorial-for-beginners/
17/03/2010 22:13
32 de 89
http://blinkdagger.com/matlab/matlab-gui-graphical-user-interface-tutorial-for-beginners/
17/03/2010 22:13
33 de 89
http://blinkdagger.com/matlab/matlab-gui-graphical-user-interface-tutorial-for-beginners/
34 de 89
http://blinkdagger.com/matlab/matlab-gui-graphical-user-interface-tutorial-for-beginners/
17/03/2010 22:13
35 de 89
http://blinkdagger.com/matlab/matlab-gui-graphical-user-interface-tutorial-for-beginners/
36 de 89
http://blinkdagger.com/matlab/matlab-gui-graphical-user-interface-tutorial-for-beginners/
% handles empty - handles not created until after all CreateFcns called
% Hint: edit controls usually have a white background on Windows.
% See ISPC and COMPUTER.
if ispc && isequal(get(hObject,BackgroundColor), get(0,defaultUicontrolBackgroundColor))
set(hObject,BackgroundColor,'white);
end
% Executes on button press in pushbutton1.
function pushbutton1_Callback(hObject, eventdata, handles)
% hObject handle to pushbutton1 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
text3=edit1+edit2; <-is this the correct way?
%text3 is the final static box
76. on 03 'ov 2008 at 3:50 am 76tasya
im 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?
77. on 10 'ov 2008 at 3:55 pm 77Chiaotinger
This is really nice!
I think I will put aside excel VBA and embrace MATLAB GUI now.
Thank you:)
78. on 18 'ov 2008 at 12:53 am 78sasi
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:
Undefined command/function myadder_mainfcn.
Error in ==> MyAdder at 42
myadder_mainfcn(myadder_State, varargin{:});
Plz help me asap.
17/03/2010 22:13
37 de 89
http://blinkdagger.com/matlab/matlab-gui-graphical-user-interface-tutorial-for-beginners/
17/03/2010 22:13
38 de 89
http://blinkdagger.com/matlab/matlab-gui-graphical-user-interface-tutorial-for-beginners/
tp20=0.015;
tu20=0.015
b=40;
a=20;
%%%%%%%%%Surface de posage secondaire%%%%%%%%%
alpha20p1 =tp20/a %alpha20p1= alpha de la phase 20 du posage primaire
beta20p1 = tp20/b
gamma20p1 = 0
u20p1 = 0
v20p1 = 0
w20p1 = tp20/2
%%%%%%%%%Surface de posage secondaire%%%%%%%%%
alpha20p2 = 0 % alpha20p2 = alpha de la phase 20 du posage secondaire
beta20p2 = tp20/a
gamma20p2 = tp20/a
u20p2 = tp20/2
v20p2 = 0
w20p2 = 0
%%%%%%%%%Surface usine%%%%%%%%%%%%%%%%%%%%%%%
alpha20u2 = 0 % alpha20u2 = alpha de la phase 20 de la surface usine
beta20u2max = tu20/a
gamma20u2max = tu20/a
u20u2max = tu20/2
v20u2 = 0
w20u2 = 0
TTRS202=[0 -beta20u2max 0; 0 beta20u2max 0; 0 0 -gamma20u2max ; 0 0 gamma20u2max ; -u20u2max 0 0 ; u20u2max 0 0]; %%%%%%
%%%%%%POLYTOPE DE L ERREUR DE L USINAGE %
% plot3(TTRS202(:,1),TTRS202(:,2),TTRS202(:,3),k.);
%
% xlabel(bettaSU20)
% ylabel(gammaSU20)
% Zlabel(uSU20)
% title(cart de la surface usine de la phase20)
%
17/03/2010 22:13
39 de 89
http://blinkdagger.com/matlab/matlab-gui-graphical-user-interface-tutorial-for-beginners/
% 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%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
TP1 = [alpha20p1 u20p1; beta20p1 v20p1; gamma20p1 w20p1]
DP1 = [u20p1; v20p1; w20p1]
ROT1 = [alpha20p1 ; beta20p1 ; gamma20p1]
%%%%%%%%%%%%%%%%%%%Surface secondaire%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
TP2 = [alpha20p2 u20p2; beta20p2 v20p2; gamma20p2 w20p2]
DP2 = [u20p2; v20p2; w20p2]
ROT2 = [alpha20p2 ; beta20p2 ; gamma20p2]
%%%%%%%%%%%%%distance vers le centre de la surface primaire%%%%%%%%
xA = 20;
yA = 10;
zA = 0;
xB = 0;
yB = 10;
zB = 10;
AB = [xB-xA; yB-yA; zB-zA]
TP2M = cross(ROT2,AB)
%%%%%%%%%%%surface secondaire vers le centre du primaire%%%%%%%%
TP2 = [alpha20p2 u20p2+TP2M(1); beta20p2 v20p2+TP2M(1); gamma20p2 w20p2+TP2M(1)]
%%%%%%%%%%%%%%Somme des torseurs des posages%%%%%%%%%%%%
17/03/2010 22:13
40 de 89
http://blinkdagger.com/matlab/matlab-gui-graphical-user-interface-tutorial-for-beginners/
41 de 89
http://blinkdagger.com/matlab/matlab-gui-graphical-user-interface-tutorial-for-beginners/
42 de 89
http://blinkdagger.com/matlab/matlab-gui-graphical-user-interface-tutorial-for-beginners/
DD20=[];
for q=1:size(TTRS202,1);
D20 = TTRS202 +
[TTRSpolyPosageMatrice(q,:);TTRSpolyPosageMatrice(q,:);TTRSpolyPosageMatrice(q,:);TTRSpolyPosageMatrice(q,:);TTRSpolyPosageMatrice(q,:);T
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
85. on 16 Dec 2008 at 9:40 pm 85Len
Thank you for the wonderful tutorial. Keep up the great work (I am referring to the website and your actual work) !!!
86. on 23 Dec 2008 at 2:45 pm 86Reza
Its Excellent!! Thank you for useful tutorial
87. on 10 Jan 2009 at 12:39 am 87Anonymous
I really liked this tutorial !! Thank you !!
I have a question, i want to display a 3D model depending on the choice of the user, using the pop-up menu in the GUI. I am lost about how to write
the code in the .m-file for this purpose.
For example, if the user selects the model pyramid from the pop-up menu, the pyramid model will be displayed. I dont know how to set the handles
to do all of this. Please help. Thanks
17/03/2010 22:13
43 de 89
http://blinkdagger.com/matlab/matlab-gui-graphical-user-interface-tutorial-for-beginners/
17/03/2010 22:13
44 de 89
http://blinkdagger.com/matlab/matlab-gui-graphical-user-interface-tutorial-for-beginners/
EDIT
mfilename, ...
gui_Singleton, ...
@time_response1_OpeningFcn, ...
17/03/2010 22:13
45 de 89
http://blinkdagger.com/matlab/matlab-gui-graphical-user-interface-tutorial-for-beginners/
17/03/2010 22:13
46 de 89
http://blinkdagger.com/matlab/matlab-gui-graphical-user-interface-tutorial-for-beginners/
17/03/2010 22:13
47 de 89
http://blinkdagger.com/matlab/matlab-gui-graphical-user-interface-tutorial-for-beginners/
% while it is up. So, bail out as we dont want to reset the data.
if isfield(handles, 'metricdata') && ~isreset
return;
end
handles.metricdata.a_input = 0;
set(handles.a_input, 'String', handles.metricdata.a_input);
17/03/2010 22:13
48 de 89
http://blinkdagger.com/matlab/matlab-gui-graphical-user-interface-tutorial-for-beginners/
17/03/2010 22:13
49 de 89
http://blinkdagger.com/matlab/matlab-gui-graphical-user-interface-tutorial-for-beginners/
may be you can post a tutorial about creating stand alone application?
most of what I found over the net isnt so simple and hard to understand.
p.s. you also can replay to my e-mail address if it is convinient for you .
Thanks .
99. on 05 Mar 2009 at 12:35 pm 99kartik
great thread !!!!!!!!!!
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.
waiting for replyy!!!!???
thank you
100. on 05 Mar 2009 at 3:59 pm 100Daniel
@ 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)
handles if you want to pass data
101. on 15 Mar 2009 at 12:08 pm 101Ahmad Jamil
Thanks very much This tutorial helped me a lot by creating my first GUI fileThanks again
102. on 18 Mar 2009 at 12:19 am 102Jorge Becerra
I have this error:
>> Calc_DistanciaRadTierraVr1Test1
??? Undefined function or variable designEval.
17/03/2010 22:13
50 de 89
http://blinkdagger.com/matlab/matlab-gui-graphical-user-interface-tutorial-for-beginners/
17/03/2010 22:13
51 de 89
http://blinkdagger.com/matlab/matlab-gui-graphical-user-interface-tutorial-for-beginners/
This requires process.m to be in the same folder as your GUI files, but if its not, you can use the addpath feature which is talked about here:
http://blinkdagger.com/?s=addpath#4
good luck,
Zane
111. on 30 Mar 2009 at 9:38 pm 111Offi
Hey! Thanks for the tutorials on your site. Theyre 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 isnt 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?
112. on 01 Apr 2009 at 2:02 am 112k8
Thank you very much!!!
113. on 08 Apr 2009 at 12:28 am 113naxus
thanks, Zane!
ill try doing that
114. on 11 Apr 2009 at 8:21 am 114vinod
this is a very good tutorial . thank u very much for this one.
115. on 14 Apr 2009 at 7:50 am 115moe
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
17/03/2010 22:13
52 de 89
http://blinkdagger.com/matlab/matlab-gui-graphical-user-interface-tutorial-for-beginners/
17/03/2010 22:13
53 de 89
http://blinkdagger.com/matlab/matlab-gui-graphical-user-interface-tutorial-for-beginners/
17/03/2010 22:13
54 de 89
http://blinkdagger.com/matlab/matlab-gui-graphical-user-interface-tutorial-for-beginners/
55 de 89
http://blinkdagger.com/matlab/matlab-gui-graphical-user-interface-tutorial-for-beginners/
17/03/2010 22:13
56 de 89
http://blinkdagger.com/matlab/matlab-gui-graphical-user-interface-tutorial-for-beginners/
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;
e.g if output of the first push button is a
and out put of second push button is b
then i want to call both thses outputs in pushbutton three to do c=a+b;
and then store to another static text
kindly answer ASAP
how to do this?
135. on 21 May 2009 at 2:17 pm 135Dou Metin
these are really very good examples for people new on matlab gui. its possible to understand easily. thanks for all.
136. on 21 May 2009 at 11:18 pm 136Praveen
Dear sir,
Thank you very much for this simple and useful tutorial on GUI in matlab, expecting more tutorials like this.
137. on 23 May 2009 at 6:49 am 137zak
hi
you cant 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
138. on 28 May 2009 at 5:35 pm 138Bilal Hussain
Thankyou brother
139. on 03 Jun 2009 at 3:12 am 139Gncel ve Gnlk Blog! | JunkChorn Hocam Sesimi Duyuyor Musun? #3
[...] Ebrar denen ahsiyet ile hi iim olmaz. Buyrun, devdeki butonlara grev atamay anlatan ok gzel bir blog. Bunun arkadan konumak
olduunu dnyor da olabilirsiniz, ama ben yargsz infaz [...]
140. on 09 Jun 2009 at 3:46 am 140asder don
Great tutorial, I still have some questions though.
17/03/2010 22:13
57 de 89
http://blinkdagger.com/matlab/matlab-gui-graphical-user-interface-tutorial-for-beginners/
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
141. on 09 Jun 2009 at 3:36 pm 141Zane Montgomery
@ 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
b
%
%
= get(handles.input1_editText,'String');
= 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
17/03/2010 22:13
58 de 89
http://blinkdagger.com/matlab/matlab-gui-graphical-user-interface-tutorial-for-beginners/
Thank you.
144. on 10 Jun 2009 at 1:17 am 144dileep d
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
145. on 10 Jun 2009 at 1:17 am 145dileep d
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.
after this i want to develope a gui for this.
Regards,
DIleep.
email id:dil639@yahoo.com
146. on 10 Jun 2009 at 9:00 am 146Anonymous
I DIDNT GET ANSWERE
FOR ANY VALUES THE ANSWERBOX SHOWS 0 ONLY
WHY
147. on 10 Jun 2009 at 9:07 am 147Anonymous
?? Reference to non-existent field input1_editText.
17/03/2010 22:13
59 de 89
http://blinkdagger.com/matlab/matlab-gui-graphical-user-interface-tutorial-for-beginners/
17/03/2010 22:13
60 de 89
http://blinkdagger.com/matlab/matlab-gui-graphical-user-interface-tutorial-for-beginners/
gui_mainfcn(gui_State, varargin{:});
Error in ==>
guidemfile>@(hObject,eventdata)MAGUI(add_pushbutton_Callback,hObject,eventdata,guidata(hObject))
??? Error while evaluating uicontrol Callback
what is the mistake
150. on 18 Jun 2009 at 10:52 am 150Quan, you're my GUI hero
Hi Quan,
Im 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 arent the greatest, and I didnt know MATLAB could make GUIs before then. I was
too scared to tell my boss that Im useless. So naturally, I turned to the internet for help.
Im so glad I found your site! Ive 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 youve really helped me out! Im suprised that Im actually excited about MATLAB now. Thanks!
I was wondering if youd perhaps do a tutorial on Active X controls someday.
Thanks again,
Joe
151. on 19 Jun 2009 at 4:42 am 151shalomi
Thank you! very helpful and clear tutorial.
152. on 19 Jun 2009 at 10:02 pm 152usha
this code great help to me.. i run add program.. how to clear text field
153. on 13 Jul 2009 at 6:39 pm 153siti
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?
154. on 20 Jul 2009 at 1:36 pm 154Meteja
Hi there.
Excellent tutorial.really help me a lot but ive 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
17/03/2010 22:13
61 de 89
http://blinkdagger.com/matlab/matlab-gui-graphical-user-interface-tutorial-for-beginners/
Thanks
155. on 22 Jul 2009 at 1:52 am 155Dhila Othman
Thank for all the guidelines.
Ita very helpful!!!!!
156. on 23 Jul 2009 at 3:49 pm 156Astromoof
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
157. on 26 Jul 2009 at 8:59 am 157Zane Montgomery
Astromoof,
It is not possible to have the inputs update while youre 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
158. on 29 Jul 2009 at 5:01 am 158lakshman
hai
thanks for ur model.
if we want take some text as input and the value of text is declared in workspace
how?
159. on 29 Jul 2009 at 9:29 pm 159Amgalan
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?
62 de 89
http://blinkdagger.com/matlab/matlab-gui-graphical-user-interface-tutorial-for-beginners/
17/03/2010 22:13
63 de 89
http://blinkdagger.com/matlab/matlab-gui-graphical-user-interface-tutorial-for-beginners/
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 string and add them together?
172. on 26 Sep 2009 at 12:00 am 172'iketan
changes made by niketan
type this at matlab command to check whether specify file is original or copied
your current dir want to be directory, where your specifed file is.
17/03/2010 22:13
64 de 89
http://blinkdagger.com/matlab/matlab-gui-graphical-user-interface-tutorial-for-beginners/
[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
createDate = direc(dateloc:(dateloc+21)); % Retrieve the creation date in a string
[y, m, d, h, mn,s] = datevec(createDate);
UserFiledate = datenum(y, m, d, h, mn,s);
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
173. on 01 Oct 2009 at 11:38 pm 173minjae
Hi, Im a university student in Korea.
This website is awesome and very useful for anyone who studies MATLAB, like me!
I sincerely appreciate your job. Thank you!
174. on 09 Oct 2009 at 5:53 pm 174Craig
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.
175. on 18 Oct 2009 at 7:09 am 175Gustav
Thanks, the example is simple and clear for beginners.
176. on 21 Oct 2009 at 4:56 am 176selva
thank you sir great tutorial,thx for the tutorial
177. on 22 Oct 2009 at 9:00 pm 177Berlyn
how can i downlaod matlab?
178. on 06 'ov 2009 at 9:53 am 178piyush
Please tell me, what code shall i include, if I want a close push button and perform a simple GUI close.
17/03/2010 22:13
65 de 89
http://blinkdagger.com/matlab/matlab-gui-graphical-user-interface-tutorial-for-beginners/
17/03/2010 22:13
66 de 89
http://blinkdagger.com/matlab/matlab-gui-graphical-user-interface-tutorial-for-beginners/
May i know how to view a web cam inside the GUI interface?
Thanks
valerie
186. on 01 Dec 2009 at 6:15 pm 186Sammy
hi
Firstly thx for your tutorials. Really helpful for beginners like me.
keep it up.
the problem im facing is that im 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.
function varargout = untitled(varargin)
% UNTITLED M-file for untitled.fig
%
UNTITLED, by itself, creates a new UNTITLED or raises the existing
%
singleton*.
%
%
H = UNTITLED returns the handle to a new UNTITLED or the handle to
%
the existing singleton*.
%
%
UNTITLED('CALLBACK',hObject,eventData,handles,...) calls the local
%
function named CALLBACK in UNTITLED.M with the given input arguments.
%
%
UNTITLED('Property','Value',...) creates a new UNTITLED or raises the
%
existing singleton*. Starting from the left, property value pairs are
%
applied to the GUI before untitled_OpeningFcn gets called. An
%
unrecognized property name or invalid value makes property application
%
stop. All inputs are passed to untitled_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
% Edit the above text to modify the response to help untitled
% Last Modified by GUIDE v2.5 02-Dec-2009 00:31:13
% Begin initialization code - DO NOT
gui_Singleton = 1;
gui_State = struct('gui_Name',
'gui_Singleton',
'gui_OpeningFcn',
EDIT
mfilename, ...
gui_Singleton, ...
@untitled_OpeningFcn, ...
17/03/2010 22:13
67 de 89
http://blinkdagger.com/matlab/matlab-gui-graphical-user-interface-tutorial-for-beginners/
17/03/2010 22:13
68 de 89
% handles
http://blinkdagger.com/matlab/matlab-gui-graphical-user-interface-tutorial-for-beginners/
17/03/2010 22:13
69 de 89
http://blinkdagger.com/matlab/matlab-gui-graphical-user-interface-tutorial-for-beginners/
%
str2double(get(hObject,'String')) returns contents of Step_editText as a double
input = str2double(get(hObject,'String'));
guidata(hObject, handles);
% --- Executes during object creation, after setting all properties.
function Step_editText_CreateFcn(hObject, eventdata, handles)
% hObject
handle to Step_editText (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles
empty - handles not created until after all CreateFcns called
% Hint: edit controls usually have a white background on Windows.
%
See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end
17/03/2010 22:13
70 de 89
http://blinkdagger.com/matlab/matlab-gui-graphical-user-interface-tutorial-for-beginners/
stop_time = get(handles.stop_editText,'String');
axes(handles.axes1)
t = [ 0 start_time step_time stop_time ]
%defining the X-axis
m = [ 0 0 1 1]
%defining the Y-axis
plot ( t,m )
%plots the graph of all the lines
%defined by 't' versus 'm'
grid on
%adds main grid lines to the current axes
xlabel ('time')
%labels the x-axis of the current axes
ylabel ('magnitude')
%labels the y-axis of the current axes
title ('plot of unit step function of user defined duration')%adds title to the current axes
guidata(hObject, handles); %updates the handles
17/03/2010 22:13
71 de 89
http://blinkdagger.com/matlab/matlab-gui-graphical-user-interface-tutorial-for-beginners/
xlabel ('Time')
ylabel ('Frequency')
title ('plot of sine wave of user defined frequency and duration')
guidata(hObject, handles); %updates the handles
plot(time,(x)), grid on
17/03/2010 22:13
72 de 89
http://blinkdagger.com/matlab/matlab-gui-graphical-user-interface-tutorial-for-beginners/
17/03/2010 22:13
73 de 89
http://blinkdagger.com/matlab/matlab-gui-graphical-user-interface-tutorial-for-beginners/
17/03/2010 22:13
74 de 89
http://blinkdagger.com/matlab/matlab-gui-graphical-user-interface-tutorial-for-beginners/
%
% EXPT4(CALLBACK,hObject,eventData,handles,) calls the local
% function named CALLBACK in EXPT4.M with the given input arguments.
%
% EXPT4(Property,'Value,) creates a new EXPT4 or raises the
% existing singleton*. Starting from the left, property value pairs are
% applied to the GUI before expt4_OpeningFcn gets called. An
% unrecognized property name or invalid value makes property application
% stop. All inputs are passed to expt4_OpeningFcn via varargin.
%
% *See GUI Options on GUIDEs Tools menu. Choose GUI allows only one
% instance to run (singleton).
%
% See also: GUIDE, GUIDATA, GUIHANDLES
% Edit the above text to modify the response to help expt4
% Last Modified by GUIDE v2.5 17-Dec-2009 23:31:08
% Begin initialization code - DO NOT EDIT
gui_Singleton = 1;
gui_State = struct(gui_Name, mfilename,
gui_Singleton, gui_Singleton,
gui_OpeningFcn, @expt4_OpeningFcn,
gui_OutputFcn, @expt4_OutputFcn,
gui_LayoutFcn, [] ,
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
% Executes just before expt4 is made visible.
function expt4_OpeningFcn(hObject, eventdata, handles, varargin)
% This function has no output args, see OutputFcn.
17/03/2010 22:13
75 de 89
http://blinkdagger.com/matlab/matlab-gui-graphical-user-interface-tutorial-for-beginners/
76 de 89
http://blinkdagger.com/matlab/matlab-gui-graphical-user-interface-tutorial-for-beginners/
end
function den_Callback(hObject, eventdata, handles)
% hObject handle to den (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Hints: get(hObject,String) returns contents of den as text
% str2double(get(hObject,String)) returns contents of den as a double
% Executes during object creation, after setting all properties.
function den_CreateFcn(hObject, eventdata, handles)
% hObject handle to den (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles empty - handles not created until after all CreateFcns called
% Hint: edit controls usually have a white background on Windows.
% See ISPC and COMPUTER.
if ispc && isequal(get(hObject,BackgroundColor), get(0,defaultUicontrolBackgroundColor))
set(hObject,BackgroundColor,'white);
end
% Executes on button press in pushbutton1.
function pushbutton1_Callback(hObject, eventdata, handles)
% hObject handle to pushbutton1 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
guidata(hobject,handles)
a=str2num(get(handles.num,String));
b=str2num(get(handles.den,String));
sys=(tf(a,b))
set(handles.text3,String,sys)
% Executes during object creation, after setting all properties.
function text3_CreateFcn(hObject, eventdata, handles)
% hObject handle to text3 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles empty - handles not created until after all CreateFcns called
197. on 18 Dec 2009 at 2:10 pm 197Kusse
17/03/2010 22:13
77 de 89
http://blinkdagger.com/matlab/matlab-gui-graphical-user-interface-tutorial-for-beginners/
17/03/2010 22:13
78 de 89
http://blinkdagger.com/matlab/matlab-gui-graphical-user-interface-tutorial-for-beginners/
gui_Singleton = 1;
gui_State = struct('gui_Name',
mfilename, ...
'gui_Singleton', gui_Singleton, ...
'gui_OpeningFcn', @demo1_OpeningFcn, ...
'gui_OutputFcn', @demo1_OutputFcn, ...
'gui_LayoutFcn', [] , ...
'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
% --- Executes just before demo1 is made visible.
function demo1_OpeningFcn(hObject, eventdata, handles, varargin)
% This function has no output args, see OutputFcn.
% hObject
handle to figure
% eventdata reserved - to be defined in a future version of MATLAB
% handles
structure with handles and user data (see GUIDATA)
% varargin
command line arguments to demo1 (see VARARGIN)
% Choose default command line output for demo1
handles.output = hObject;
set(hObject,'toolbar','figure');
% Update handles structure
guidata(hObject, handles);
% UIWAIT makes demo1 wait for user response (see UIRESUME)
% uiwait(handles.figure1);
% --- 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)
% Get default command line output from handles structure
varargout{1} = handles.output;
% --- Executes on button press in pushbutton1.
function pushbutton1_Callback(hObject, eventdata, handles)
% hObject
handle to pushbutton1 (see GCBO)
17/03/2010 22:13
79 de 89
http://blinkdagger.com/matlab/matlab-gui-graphical-user-interface-tutorial-for-beginners/
If my input is sin(2*pi*50*t)
but program cant read t
t=time
what should i do ?
203. on 21 Jan 2010 at 5:32 pm 203Yunus
Thank you for such a clear tutorial. It really helps.
204. on 03 Feb 2010 at 7:33 pm 204shill123
Hello..
M designing DTMF encoder/decoder in matlab using GUI..
17/03/2010 22:13
80 de 89
http://blinkdagger.com/matlab/matlab-gui-graphical-user-interface-tutorial-for-beginners/
here i want a figure to be displayed by checking a push button press in someother callback function,, how to do it??
205. on 04 Feb 2010 at 1:32 am 205Anshul
Thank you very much for such great tutorial.
206. on 05 Feb 2010 at 1:05 am 206amit hansani
hello,
my final year project is based on image segmentation using fuzzy connectednesscan u plz guide me through this.how can i include a image in
matlab using GUI
207. on 10 Feb 2010 at 12:10 pm 207Kerem
Hi,
Thanks a lot for such a nice and simple to understand GUI tutorial
208. on 13 Feb 2010 at 6:28 pm 208lakshman
simply great tutorialvery lucid and easy to understand..thanks a lot
209. on 15 Feb 2010 at 4:49 pm 209AkilaMike
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.
210. on 15 Feb 2010 at 11:21 pm 210Iris
Thanks for your tutorial! Its 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 into?
Thanks,
Iris
17/03/2010 22:13
81 de 89
http://blinkdagger.com/matlab/matlab-gui-graphical-user-interface-tutorial-for-beginners/
17/03/2010 22:13
82 de 89
http://blinkdagger.com/matlab/matlab-gui-graphical-user-interface-tutorial-for-beginners/
gui_OutputFcn, @myadder_OutputFcn,
gui_LayoutFcn, [] ,
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
% Executes just before myadder is made visible.
function myadder_OpeningFcn(hObject, eventdata, handles, varargin)
% This function has no output args, see OutputFcn.
% hObject handle to figure
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% varargin command line arguments to myadder (see VARARGIN)
% Choose default command line output for myadder
handles.output = hObject;
% Update handles structure
guidata(hObject, handles);
% UIWAIT makes myadder wait for user response (see UIRESUME)
% uiwait(handles.figure1);
% Outputs from this function are returned to the command line.
function varargout = myadder_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)
% Get default command line output from handles structure
varargout{1} = handles.output;
17/03/2010 22:13
83 de 89
http://blinkdagger.com/matlab/matlab-gui-graphical-user-interface-tutorial-for-beginners/
17/03/2010 22:13
84 de 89
http://blinkdagger.com/matlab/matlab-gui-graphical-user-interface-tutorial-for-beginners/
if (isempty(input))
set(hObject,String,'0)
end
guidata(hObject, handles);
% Executes during object creation, after setting all properties.
function input2_editText_CreateFcn(hObject, eventdata, handles)
% hObject handle to input2_editText (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles empty - handles not created until after all CreateFcns called
% Hint: edit controls usually have a white background on Windows.
% See ISPC and COMPUTER.
if ispc && isequal(get(hObject,BackgroundColor), get(0,defaultUicontrolBackgroundColor))
set(hObject,BackgroundColor,'white);
end
% 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)
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
total = str2num(a) + str2num(b);
c = num2str(total);
% need to convert the answer back into String type to display it
set(handles.answer_staticText,String,c);
guidata(hObject, handles);
213. on 26 Feb 2010 at 7:13 am 213Debasish Sarker
Plz..help me..and if possible email me to my email address.
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.
17/03/2010 22:13
85 de 89
http://blinkdagger.com/matlab/matlab-gui-graphical-user-interface-tutorial-for-beginners/
How can I manage gui.m file of this problem?? anyone please help me..
214. on 04 Mar 2010 at 11:15 pm 214Ritu
Hi,
I m really Thankfull 2 u for this nice and easily understandable tutorial.
215. on 05 Mar 2010 at 3:05 am 215Alen
Hi, can you teach me how to generate sine wave in GUI?
Thank you
216. on 07 Mar 2010 at 1:45 am 216Anonymous
supper
217. on 08 Mar 2010 at 9:59 am 217elea
thank you so much for the tutorial
218. on 13 Mar 2010 at 7:58 am 218dut eden
hey i have one Q
how to get read for a matrix form..eg: i want to read 2000 4000 in static text both at the same time..
219. on 13 Mar 2010 at 6:50 pm 219raj
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
plzz help me out
220. on 13 Mar 2010 at 6:53 pm 220raj
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
17/03/2010 22:13
86 de 89
http://blinkdagger.com/matlab/matlab-gui-graphical-user-interface-tutorial-for-beginners/
Leave a Reply
Include MATLAB code in your comment by doing the following:
<pre lang="MATLAB">
%insert code here
</pre>
Name
Mail (hidden)
Website
17/03/2010 22:13
87 de 89
www.DoDBU.com
http://blinkdagger.com/matlab/matlab-gui-graphical-user-interface-tutorial-for-beginners/
Ads by Google
17/03/2010 22:13
88 de 89
http://blinkdagger.com/matlab/matlab-gui-graphical-user-interface-tutorial-for-beginners/
Ads by Google
Gui Programming
Download Java Games
Gui Interface
Windows Forms Gui
Links
The MathWorks Blog Ring
Undocumented MATLAB Tips
Data Mining in MATLAB
Search for:
Recent Posts
The End of Blinkdagger? . . . . Possibly
MATLAB - Global Variables
MMM #34 Winner, Sander Land!!!
Monday Math Madness #34: Crossing a Bridge
MATLAB GUI Tutorial - UITABLE Part 2, How To Access Table Data
Copyright 2010 blinkdagger
Posts RSS Comments RSS
17/03/2010 22:13
89 de 89
http://blinkdagger.com/matlab/matlab-gui-graphical-user-interface-tutorial-for-beginners/
17/03/2010 22:13