<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Tayyab Bin Tariq &#187; Digital Image Processing</title>
	<atom:link href="http://tayyab.xenoglaux-solutions.com/category/digital-image-processing/feed/" rel="self" type="application/rss+xml" />
	<link>http://tayyab.xenoglaux-solutions.com</link>
	<description>I like sharing what i know</description>
	<lastBuildDate>Fri, 21 May 2010 20:59:02 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.6</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Matlab GUI-Radio Buttons: What I learnt Today?</title>
		<link>http://tayyab.xenoglaux-solutions.com/2010/04/25/matlab-gui-radio-buttons-what-i-learnt-today/</link>
		<comments>http://tayyab.xenoglaux-solutions.com/2010/04/25/matlab-gui-radio-buttons-what-i-learnt-today/#comments</comments>
		<pubDate>Sun, 25 Apr 2010 15:03:25 +0000</pubDate>
		<dc:creator>tayyabtariq</dc:creator>
				<category><![CDATA[Computer Programming]]></category>
		<category><![CDATA[Matlab]]></category>
		<category><![CDATA[WILT]]></category>
		<category><![CDATA[Matlab GUI]]></category>
		<category><![CDATA[matlab radio buttons]]></category>
		<category><![CDATA[radio  buttons]]></category>
		<category><![CDATA[What I Learnt Today?]]></category>

		<guid isPermaLink="false">http://tayyab.xenoglaux-solutions.com/2010/04/25/matlab-gui-radio-buttons-what-i-learnt-today/</guid>
		<description><![CDATA[Introduction
 In this Matlab GUI Tutorial, you will learn how to use radio buttons, toggle buttons and the button group panel.
&#160;
 
Radio buttons and Toggle buttons are used exactly the same way that check boxes are used in Matlab GUIs, so we won’t go over how to use them. But there is one special case [...]]]></description>
			<content:encoded><![CDATA[<h2>Introduction</h2>
<p><img hspace="10" alt="Matlab Logo" align="left" src="http://www.blinkdagger.com/tutorials/matlab/matlab-icon.jpg" /> In this Matlab GUI Tutorial, you will learn how to use radio buttons, toggle buttons and the button group panel.</p>
<p>&#160;</p>
<p> <span id="more-190"></span>
<p>Radio buttons and Toggle buttons are used exactly the same way that check boxes are used in Matlab GUIs, so we won’t go over how to use them. But there is one special case that needs to be covered. When either radio buttons or toggle buttons are used in conjunction with the button group panel, they exhibit mutually exclusive behavior. Simply put, this means that only one radio button or one toggle button can be selected at a time. This behavior can come in very useful for some GUIs. Since radio buttons and toggle buttons are identical in their functionality, what is said about one, is true for the other. Thus, only radio buttions will be discussed from here on out. </p>
<p>In this part of the tutorial, we will create a button group that will allow you to choose between different font sizes for the display text. </p>
<ol>
<li>
<p>The first thing we need to do is to add a <em>Button Panel</em> component to the GUI figure that we were just working with. So if you closed GUIDE, reopen it again. Once you have GUIDE opened again, click on <img border="1" alt="button panel icon" src="http://www.blinkdagger.com/tutorials/matlab/GUI/basic/beginner/buttonpanel-icon.png" /> and add one <em>Button Panel</em> component to the GUI figure. Make sure it’s large enough to fit in three radio buttons. Next, click on <img border="1" alt="radio button icon" src="http://www.blinkdagger.com/tutorials/matlab/GUI/basic/beginner/radiobutton-icon.png" /> and add three radio buttons onto the button group panel.</p>
</li>
<li>
<p>Double click on the first <em>Radio Button</em> component to bring up the Property Inspector. Change the <em>String</em> property to <code>8</code>. Change the <em>Tag</em> property to <code>fontsize08_radiobutton</code>. </p>
<p><img alt="Modify radio component properties" src="http://www.blinkdagger.com/tutorials/matlab/GUI/basic/buttons/image019.png" /></p>
<p>Next, double click on the second <em>Radio Button</em> component, and change the <em>String</em> property to <code>12</code>, and change the <em>Tag</em> property to <code>fontsize12_radiobutton</code>. </p>
<p>Next, double click on the third <em>Radio Button</em> component, and change the <em>String</em> property to <code>16</code>, and change the <em>Tag</em> property to <code>fontsize16_radiobutton</code>. </p>
<p>Finally, double click on the button group panel and change the <em>Tag</em> property to <code>fontSelect_buttongroup</code>. You should also change the <em>String</em> property for the button group panel to <code>Fontsize</code>.</p>
</li>
<li>
<p>Here’s what your figure should look like after you add the components and modify them.</p>
<p><img alt="What your GUI figure should look like" src="http://www.blinkdagger.com/tutorials/matlab/GUI/basic/buttons/image021.png" /></p>
</li>
<li>
<p>Before we move on, we should check the hierarchical structure of the GUI figure. Click on the <img border="1" alt="object browswer icon" src="http://www.blinkdagger.com/tutorials/matlab/GUI/basic/buttons/objectBrowser-icon.png" /> icon and the followinging should appear:</p>
<p><img alt="object browswer " src="http://www.blinkdagger.com/tutorials/matlab/GUI/basic/buttons/objectBrowser.png" /></p>
<p>Make sure that the three radio buttons are one hierarchy below the button group icon.</p>
</li>
<li>
<p>Add the following line of code to the opening function. In this tutorial example, it is named <em>button_tutorial_OpeningFcn</em> function. Yours will be the name of the file you saved it as, followed by “_OpeningFcn”.</p>
<pre>set(handles.fontSelect_buttongroup,'SelectionChangeFcn',@fontSelect_buttongroup_SelectionChangeFcn);</pre>
<p>Make sure the previous line was added right before the line:</p>
<pre>guidata(hObject, handles);</pre>
<p>Next, add the following function at the very end of the .m file.</p>
<pre>function fontSelect_buttongroup_SelectionChangeFcn(hObject, eventdata)&#160;&#160; %retrieve GUI data, i.e. the handles structure
handles = guidata(hObject);&#160;&#160; switch get(eventdata.NewValue,'Tag')   % Get Tag of selected object
    case 'fontsize08_radiobutton'
      %execute this code when fontsize08_radiobutton is selected
      set(handles.display_staticText,'FontSize',8);&#160;&#160; case 'fontsize12_radiobutton'
      %execute this code when fontsize12_radiobutton is selected
      set(handles.display_staticText,'FontSize',12);&#160;&#160; case 'fontsize16_radiobutton'
      %execute this code when fontsize16_radiobutton is selected
      set(handles.display_staticText,'FontSize',16);
    otherwise
       % Code for when there is no match.&#160;&#160; end
%updates the handles structure
guidata(hObject, handles);</pre>
</li>
<li>
<p>Notice that the callback functions for the radio buttons were not automatically generated by Matlab. This is completely normal. Each time a button is selected within the <em>Button Group Panel</em> component, the function defined within the <em>SelectionChangeFcn</em> property of <em>Button Group Panel</em> component is called. The line of code that was added in the opening function specifies the callback function when a button within the button group is selcted. The selection change function is then defined at the end of the .m file.</p>
</li>
<li>
<p>Now that we’ve completed both the visual and code aspects of the GUI, its time to run the GUI again. Try clicking on all of the buttons to make sure they perform their function correctly. Specifically, make sure that the font size changes accordingly.</p>
<p><img alt="Buttons GUI" src="http://www.blinkdagger.com/tutorials/matlab/GUI/basic/buttons/image023.png" /></p>
</li>
</ol>
<p>And that’s it. Those are the basics of using the different buttons within the Matlab GUI.</p>
<p class="facebook"><a href="http://www.facebook.com/share.php?u=http://tayyab.xenoglaux-solutions.com/2010/04/25/matlab-gui-radio-buttons-what-i-learnt-today/" target="_blank"><img src="http://tayyab.xenoglaux-solutions.com/wp-content/plugins/add-to-facebook-plugin/facebook_share_icon.gif" alt="Share on Facebook" title="Share on Facebook" /></a><a href="http://www.facebook.com/share.php?u=http://tayyab.xenoglaux-solutions.com/2010/04/25/matlab-gui-radio-buttons-what-i-learnt-today/" target="_blank" title="Share on Facebook">Share on Facebook</a></p>]]></content:encoded>
			<wfw:commentRss>http://tayyab.xenoglaux-solutions.com/2010/04/25/matlab-gui-radio-buttons-what-i-learnt-today/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Google goggles</title>
		<link>http://tayyab.xenoglaux-solutions.com/2009/12/20/google-goggles/</link>
		<comments>http://tayyab.xenoglaux-solutions.com/2009/12/20/google-goggles/#comments</comments>
		<pubDate>Sat, 19 Dec 2009 19:40:39 +0000</pubDate>
		<dc:creator>tayyabtariq</dc:creator>
				<category><![CDATA[Digital Image Processing]]></category>
		<category><![CDATA[Misc]]></category>
		<category><![CDATA[Content Based Image Retrieval]]></category>
		<category><![CDATA[Google]]></category>
		<category><![CDATA[Google goggles]]></category>
		<category><![CDATA[Image Processing]]></category>

		<guid isPermaLink="false">http://tayyab.xenoglaux-solutions.com/2009/12/20/google-goggles/</guid>
		<description><![CDATA[Google has recently launched its latest in image search, called Google Goggles. It is an application for Android operating system that allows a user to perform searches based on images instead of text.
According to the official statement “Google Goggles works best on books &#38; DVDs, landmarks, logos, contact info, artwork, businesses, products, barcodes, or text. [...]]]></description>
			<content:encoded><![CDATA[<p>Google has recently launched its latest in image search, called Google Goggles. It is an application for Android operating system that allows a user to perform searches based on images instead of text.</p>
<p>According to the official statement “Google Goggles works best on books &amp; DVDs, landmarks, logos, contact info, artwork, businesses, products, barcodes, or text. Right now, it&#8217;s not so good at pictures of animals, plants, cars, furniture, or apparel”. </p>
<p>It does not surprise me that Google has developed this application. What is most interesting is how quickly Google has transformed ongoing research into a product. It was only a few months back that I read the Google paper on landmark identification, and here it is neatly bundled into an application. </p>
<p>My interest in Computer Vision and object recognition also makes me wonder as to how the folks at Google were able to make all this work at such a large scale. The paper I reference above provides clues but the transforming the said research into an application has some serious data flow problems. One answer can be inferred from the statement quoted above. The user has has to specify a category before with the search image. Meaning there is some case specific optimization involved. If this is true, the image search problem in the general case is still un solved! </p>
<div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:5737277B-5D6D-4f48-ABFC-DD9C333F4C5D:2a41fd7f-b2d4-41f3-b3a0-01639e118ac8" class="wlWriterEditableSmartContent">
<div><object width="425" height="355"><param name="movie" value="http://www.youtube.com/v/Hhgfz0zPmH4&amp;hl=en"></param><embed src="http://www.youtube.com/v/Hhgfz0zPmH4&amp;hl=en" type="application/x-shockwave-flash" width="425" height="355"></embed></object></div>
</div>
<p>Here are some links:</p>
<p><a href="http://www.google.com/mobile/goggles/">http://www.google.com/mobile/goggles/</a></p>
<p><a title="http://www.google.com/googleblogs/pdfs/google_landmark_recognition.pdf" href="http://www.google.com/googleblogs/pdfs/google_landmark_recognition.pdf">http://www.google.com/googleblogs/pdfs/google_landmark_recognition.pdf</a></p>
<p class="facebook"><a href="http://www.facebook.com/share.php?u=http://tayyab.xenoglaux-solutions.com/2009/12/20/google-goggles/" target="_blank"><img src="http://tayyab.xenoglaux-solutions.com/wp-content/plugins/add-to-facebook-plugin/facebook_share_icon.gif" alt="Share on Facebook" title="Share on Facebook" /></a><a href="http://www.facebook.com/share.php?u=http://tayyab.xenoglaux-solutions.com/2009/12/20/google-goggles/" target="_blank" title="Share on Facebook">Share on Facebook</a></p>]]></content:encoded>
			<wfw:commentRss>http://tayyab.xenoglaux-solutions.com/2009/12/20/google-goggles/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Google Image Search: New Options</title>
		<link>http://tayyab.xenoglaux-solutions.com/2009/07/26/google-image-search-new-options/</link>
		<comments>http://tayyab.xenoglaux-solutions.com/2009/07/26/google-image-search-new-options/#comments</comments>
		<pubDate>Sat, 25 Jul 2009 19:06:48 +0000</pubDate>
		<dc:creator>tayyabtariq</dc:creator>
				<category><![CDATA[Digital Image Processing]]></category>
		<category><![CDATA[Technology]]></category>
		<category><![CDATA[Google]]></category>
		<category><![CDATA[Google Image Search]]></category>
		<category><![CDATA[Image Processing]]></category>

		<guid isPermaLink="false">http://tayyab.xenoglaux-solutions.com/2009/07/26/google-image-search-new-options/</guid>
		<description><![CDATA[Recently I noticed some new features on Google Image Search. The image search that was awesome already has added some two great new options. Whenever you search for an image, you can select a type and color. 
You can select from a number of types; News, Face, Clip art, Line drawings and Photo. The filtered [...]]]></description>
			<content:encoded><![CDATA[<p>Recently I noticed some new features on Google Image Search. The image search that was awesome already has added some two great new options. Whenever you search for an image, you can select a type and color. </p>
<p>You can select from a number of types; News, Face, Clip art, Line drawings and Photo. The filtered results are extremely quick and accurate. Moreover, you can also choose a color and Google would give you the images where the selected image is dominant. </p>
<p>Being interested in Image processing myself I know that the second is pretty easy but, categorizing the images between News, Face, Clip art, Line drawings and Photo is pretty darn difficult. </p>
<p>I am a little awe struck and I little worried about my FYP now <img src='http://tayyab.xenoglaux-solutions.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p class="facebook"><a href="http://www.facebook.com/share.php?u=http://tayyab.xenoglaux-solutions.com/2009/07/26/google-image-search-new-options/" target="_blank"><img src="http://tayyab.xenoglaux-solutions.com/wp-content/plugins/add-to-facebook-plugin/facebook_share_icon.gif" alt="Share on Facebook" title="Share on Facebook" /></a><a href="http://www.facebook.com/share.php?u=http://tayyab.xenoglaux-solutions.com/2009/07/26/google-image-search-new-options/" target="_blank" title="Share on Facebook">Share on Facebook</a></p>]]></content:encoded>
			<wfw:commentRss>http://tayyab.xenoglaux-solutions.com/2009/07/26/google-image-search-new-options/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>From Rajesh Koothrappali to Tayyab Tariq in 30 lines of code</title>
		<link>http://tayyab.xenoglaux-solutions.com/2009/05/24/from-rajesh-koothrappali-to-tayyab-tariq-in-30-lines-of-code/</link>
		<comments>http://tayyab.xenoglaux-solutions.com/2009/05/24/from-rajesh-koothrappali-to-tayyab-tariq-in-30-lines-of-code/#comments</comments>
		<pubDate>Sat, 23 May 2009 20:51:57 +0000</pubDate>
		<dc:creator>tayyabtariq</dc:creator>
				<category><![CDATA[Digital Image Processing]]></category>
		<category><![CDATA[Matlab]]></category>
		<category><![CDATA[Butterworth Low Pass Filter]]></category>
		<category><![CDATA[Histogram Equalization]]></category>
		<category><![CDATA[Matlab GUI]]></category>

		<guid isPermaLink="false">http://tayyab.xenoglaux-solutions.com/2009/05/24/from-rajesh-koothrappali-to-tayyab-tariq-in-30-lines-of-code/</guid>
		<description><![CDATA[First thing, I am sorry if someone finds it offensive or racist, I just meant it to be funny and for the record, Rajesh Koothrappali is my favorite Big Band Theory character.
 
A friend of mine posted this picture of me on Facebook. In the same days I had studied a few topics in my [...]]]></description>
			<content:encoded><![CDATA[<p>First thing, I am sorry if someone finds it offensive or racist, I just meant it to be funny and for the record, Rajesh Koothrappali is my favorite Big Band Theory character.</p>
<p><a href="http://tayyab.xenoglaux-solutions.com/wp-content/uploads/2009/05/image13.png"><img title="image" style="border-right: 0px; border-top: 0px; display: inline; border-left: 0px; border-bottom: 0px" height="364" alt="image" src="http://tayyab.xenoglaux-solutions.com/wp-content/uploads/2009/05/image-thumb13.png" width="644" border="0" /></a> </p>
<p>A friend of mine posted this picture of me on Facebook. In the same days I had studied a few topics in my Digital Image Processing course on how to correct certain types of images. So I applied histogram equalization on the image followed by a butterwoth low pass filter, using Matlab code. </p>
<p>If anyone wants the code, please leave a comment.</p>
<p class="facebook"><a href="http://www.facebook.com/share.php?u=http://tayyab.xenoglaux-solutions.com/2009/05/24/from-rajesh-koothrappali-to-tayyab-tariq-in-30-lines-of-code/" target="_blank"><img src="http://tayyab.xenoglaux-solutions.com/wp-content/plugins/add-to-facebook-plugin/facebook_share_icon.gif" alt="Share on Facebook" title="Share on Facebook" /></a><a href="http://www.facebook.com/share.php?u=http://tayyab.xenoglaux-solutions.com/2009/05/24/from-rajesh-koothrappali-to-tayyab-tariq-in-30-lines-of-code/" target="_blank" title="Share on Facebook">Share on Facebook</a></p>]]></content:encoded>
			<wfw:commentRss>http://tayyab.xenoglaux-solutions.com/2009/05/24/from-rajesh-koothrappali-to-tayyab-tariq-in-30-lines-of-code/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Matlab GUI: Handling User Data and Images</title>
		<link>http://tayyab.xenoglaux-solutions.com/2009/04/06/matlab-gui-handling-user-data-and-images/</link>
		<comments>http://tayyab.xenoglaux-solutions.com/2009/04/06/matlab-gui-handling-user-data-and-images/#comments</comments>
		<pubDate>Mon, 06 Apr 2009 17:00:35 +0000</pubDate>
		<dc:creator>tayyabtariq</dc:creator>
				<category><![CDATA[Matlab]]></category>
		<category><![CDATA[Application Data]]></category>
		<category><![CDATA[getuserdata]]></category>
		<category><![CDATA[GUIDE]]></category>
		<category><![CDATA[imread]]></category>
		<category><![CDATA[imshow]]></category>
		<category><![CDATA[Matlab GUI]]></category>
		<category><![CDATA[Matlab GUI: Handling User Data and Images]]></category>
		<category><![CDATA[Matlab Image]]></category>
		<category><![CDATA[Matlab User Data]]></category>
		<category><![CDATA[setuserdata]]></category>
		<category><![CDATA[User Data]]></category>

		<guid isPermaLink="false">http://tayyab.xenoglaux-solutions.com/2009/04/06/matlab-gui-handling-user-data-and-images/</guid>
		<description><![CDATA[ 
It is often an issue to handle user defined data when working with Matlab GUI. In this tutorial I show how to share user data among functions and how to handle Images.
&#160;
&#160;
&#160;
 
I assume basic knowledge of Matlab GUI. (Please see the tutorial on GUI basics).
We create a simple GUI where a user can [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://tayyab.xenoglaux-solutions.com/wp-content/uploads/2009/04/matlab1.jpg"><img title="matlab" style="border-top-width: 0px; display: inline; border-left-width: 0px; border-bottom-width: 0px; margin: 10px 0px; border-right-width: 0px" height="184" alt="matlab" src="http://tayyab.xenoglaux-solutions.com/wp-content/uploads/2009/04/matlab-thumb1.jpg" width="244" align="left" border="0" /></a> </p>
<p>It is often an issue to handle user defined data when working with Matlab GUI. In this tutorial I show how to share user data among functions and how to handle Images.</p>
<p>&#160;</p>
<p>&#160;</p>
<p>&#160;</p>
<p> <span id="more-34"></span>
<p>I assume basic knowledge of Matlab GUI. (Please see the tutorial on <a href="http://tayyab.xenoglaux-solutions.com/2009/04/06/creating-matlab-gui-the-basics/" target="_blank">GUI basics</a>).</p>
<p>We create a simple GUI where a user can select an image and then press a button to display it.</p>
<p><a href="http://tayyab.xenoglaux-solutions.com/wp-content/uploads/2009/04/image6.png"><img title="image" style="border-top-width: 0px; display: inline; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" height="379" alt="image" src="http://tayyab.xenoglaux-solutions.com/wp-content/uploads/2009/04/image-thumb6.png" width="644" border="0" /></a> </p>
<p>First create a simple GUI with an edit box and two push buttons.</p>
<p><a href="http://tayyab.xenoglaux-solutions.com/wp-content/uploads/2009/04/image7.png"><img title="image" style="border-top-width: 0px; display: inline; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" height="316" alt="image" src="http://tayyab.xenoglaux-solutions.com/wp-content/uploads/2009/04/image-thumb7.png" width="644" border="0" /></a> </p>
<p>The plan of action is to allow the user to select a file when he/she presses the ‘Browse’ button, and show the image when he ‘Show Image’ button is pressed.</p>
<h3>Reading Images and Setting User Data</h3>
<p>In the ‘Browse’ button call back i add the following code.</p>
<div id="codeSnippetWrapper" style="border-right: silver 1px solid; padding-right: 4px; border-top: silver 1px solid; padding-left: 4px; font-size: 8pt; padding-bottom: 4px; margin: 20px 0px 10px; overflow: auto; border-left: silver 1px solid; width: 97.5%; cursor: text; direction: ltr; max-height: 200px; line-height: 12pt; padding-top: 4px; border-bottom: silver 1px solid; font-family: &#39;Courier New&#39;, courier, monospace; background-color: #f4f4f4; text-align: left">
<div id="codeSnippet" style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; text-align: left; border-bottom-style: none">
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; text-align: left; border-bottom-style: none"><span id="lnum1" style="color: #606060">   1:</span> % get a file to read </pre>
<p><!--CRLF--></p>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; text-align: left; border-bottom-style: none"><span id="lnum2" style="color: #606060">   2:</span> [FileName, FilePath] = uigetfile({ <span style="color: #006080">'*.jpg'</span>; <span style="color: #006080">'*.jpeg'</span>; <span style="color: #006080">'*.bmp'</span>; <span style="color: #006080">'*.gif'</span>; <span style="color: #006080">'*.tiff'</span>; <span style="color: #006080">'*.png'</span> }, <span style="color: #006080">'Select an Image...'</span>);</pre>
<p><!--CRLF--></p>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; text-align: left; border-bottom-style: none"><span id="lnum3" style="color: #606060">   3:</span> % set the file name and path to the edit box as well</pre>
<p><!--CRLF--></p>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; text-align: left; border-bottom-style: none"><span id="lnum4" style="color: #606060">   4:</span> set(handles.editFilePath, <span style="color: #006080">'String'</span>, [FilePath, FileName]);</pre>
<p><!--CRLF--></p>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; text-align: left; border-bottom-style: none"><span id="lnum5" style="color: #606060">   5:</span> % read the image</pre>
<p><!--CRLF--></p>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; text-align: left; border-bottom-style: none"><span id="lnum6" style="color: #606060">   6:</span> I = imread([FilePath, FileName]);</pre>
<p><!--CRLF--></p>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; text-align: left; border-bottom-style: none"><span id="lnum7" style="color: #606060">   7:</span> % set the image <span style="color: #0000ff">in</span> the user data, <span style="color: #0000ff">if</span> this is not done, the image would be</pre>
<p><!--CRLF--></p>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; text-align: left; border-bottom-style: none"><span id="lnum8" style="color: #606060">   8:</span> % lost</pre>
<p><!--CRLF--></p>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; text-align: left; border-bottom-style: none"><span id="lnum9" style="color: #606060">   9:</span> setappdata(JigsawPuzzle, <span style="color: #006080">'MyImage'</span>, I);</pre>
<p><!--CRLF--></p>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; text-align: left; border-bottom-style: none"><span id="lnum10" style="color: #606060">  10:</span> % set the file name and path <span style="color: #0000ff">in</span> the user data</pre>
<p><!--CRLF--></p>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; text-align: left; border-bottom-style: none"><span id="lnum11" style="color: #606060">  11:</span> setappdata(JigsawPuzzle, <span style="color: #006080">'FileNameAndPath'</span>, [FilePath, FileName]);</pre>
<p><!--CRLF--></div>
</div>
<p>The last two lines are the most important and need explanation.</p>
<p><font face="Courier"><a href="http://www.mathworks.com/access/helpdesk/help/techdoc/index.html?/access/helpdesk/help/techdoc/ref/setappdata.html&amp;http://www.mathworks.com/access/helpdesk/help/techdoc/creating_guis/f5-998352.html" target="_blank">setappdata</a>(JigsawPuzzle, &#8216;MyImage&#8217;, I);</font></p>
<p>The first argument of the ‘setappdata’ is the name of a figure object or any object contained within it that will hold the data as its data object, you could use any control but I use the figure itself to assert the global scope of the variables. The second argument is the name of the data variable. The third argument is the data itself.</p>
<p>The last line sets another variable with filename and path, concatenated together.</p>
<p>PS: You might want to read about uigetfile (Use help uigetfile in Matlab).</p>
<p>I have also added similar code to the edit box.</p>
<div id="codeSnippetWrapper" style="border-right: silver 1px solid; padding-right: 4px; border-top: silver 1px solid; padding-left: 4px; font-size: 8pt; padding-bottom: 4px; margin: 20px 0px 10px; overflow: auto; border-left: silver 1px solid; width: 106.96%; cursor: text; direction: ltr; max-height: 200px; line-height: 12pt; padding-top: 4px; border-bottom: silver 1px solid; font-family: &#39;Courier New&#39;, courier, monospace; height: 123px; background-color: #f4f4f4; text-align: left">
<div id="codeSnippet" style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; text-align: left; border-bottom-style: none">
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; text-align: left; border-bottom-style: none"><span id="lnum1" style="color: #606060">   1:</span> FilePath = get(handles.editFilePath, <span style="color: #006080">'String'</span>);</pre>
<p><!--CRLF--></p>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; text-align: left; border-bottom-style: none"><span id="lnum2" style="color: #606060">   2:</span> set(handles.editFilePath, <span style="color: #006080">'String'</span>, FilePath);</pre>
<p><!--CRLF--></p>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; text-align: left; border-bottom-style: none"><span id="lnum3" style="color: #606060">   3:</span> I = imread(FilePath);</pre>
<p><!--CRLF--></p>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; text-align: left; border-bottom-style: none"><span id="lnum4" style="color: #606060">   4:</span> setappdata(JigsawPuzzle, <span style="color: #006080">'MyImage'</span>, I);</pre>
<p><!--CRLF--></p>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; text-align: left; border-bottom-style: none"><span id="lnum5" style="color: #606060">   5:</span> setappdata(JigsawPuzzle, <span style="color: #006080">'FileNameAndPath'</span>, FilePath);</pre>
<p><!--CRLF--></div>
</div>
<h3>Retrieving User Data and Showing the image</h3>
<p>This part is rather simpler. I add the following code to the show image button.</p>
<div id="codeSnippetWrapper" style="border-right: silver 1px solid; padding-right: 4px; border-top: silver 1px solid; padding-left: 4px; font-size: 8pt; padding-bottom: 4px; margin: 20px 0px 10px; overflow: auto; border-left: silver 1px solid; width: 97.5%; cursor: text; direction: ltr; max-height: 200px; line-height: 12pt; padding-top: 4px; border-bottom: silver 1px solid; font-family: &#39;Courier New&#39;, courier, monospace; background-color: #f4f4f4; text-align: left">
<div id="codeSnippet" style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; text-align: left; border-bottom-style: none">
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; text-align: left; border-bottom-style: none"><span id="lnum1" style="color: #606060">   1:</span> Image = getappdata(JigsawPuzzle, <span style="color: #006080">'MyImage'</span>);</pre>
<p><!--CRLF--></p>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; text-align: left; border-bottom-style: none"><span id="lnum2" style="color: #606060">   2:</span> figure, imshow(Image);</pre>
<p><!--CRLF--></div>
</div>
<p>The&#160; <a href="http://www.mathworks.com/access/helpdesk/help/techdoc/index.html?/access/helpdesk/help/techdoc/ref/getappdata.html" target="_blank">getappdata</a> is similar to get function used to retrieve values for control properties.</p>
<p>Please feel free to leave comments and questions.</p>
<p class="facebook"><a href="http://www.facebook.com/share.php?u=http://tayyab.xenoglaux-solutions.com/2009/04/06/matlab-gui-handling-user-data-and-images/" target="_blank"><img src="http://tayyab.xenoglaux-solutions.com/wp-content/plugins/add-to-facebook-plugin/facebook_share_icon.gif" alt="Share on Facebook" title="Share on Facebook" /></a><a href="http://www.facebook.com/share.php?u=http://tayyab.xenoglaux-solutions.com/2009/04/06/matlab-gui-handling-user-data-and-images/" target="_blank" title="Share on Facebook">Share on Facebook</a></p>]]></content:encoded>
			<wfw:commentRss>http://tayyab.xenoglaux-solutions.com/2009/04/06/matlab-gui-handling-user-data-and-images/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>Creating Matlab GUI: The basics</title>
		<link>http://tayyab.xenoglaux-solutions.com/2009/04/06/creating-matlab-gui-the-basics/</link>
		<comments>http://tayyab.xenoglaux-solutions.com/2009/04/06/creating-matlab-gui-the-basics/#comments</comments>
		<pubDate>Mon, 06 Apr 2009 15:10:21 +0000</pubDate>
		<dc:creator>tayyabtariq</dc:creator>
				<category><![CDATA[Matlab]]></category>
		<category><![CDATA[Matlab GUI]]></category>

		<guid isPermaLink="false">http://tayyab.xenoglaux-solutions.com/2009/04/06/creating-matlab-gui-the-basics/</guid>
		<description><![CDATA[Matlab is a very useful tool for doing a number of things and to a number of people especially researchers due to its very short development time. Having a command line driven interface however can be unlikable at times. Matlab however provides a great GUI interface and tolls to&#160; create the GUIs.
Here is a simple [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://tayyab.xenoglaux-solutions.com/wp-content/uploads/2009/04/matlab.jpg"><img title="matlab" style="border-right: 0px; border-top: 0px; display: inline; margin: 10px; border-left: 0px; border-bottom: 0px" height="184" alt="matlab" src="http://tayyab.xenoglaux-solutions.com/wp-content/uploads/2009/04/matlab-thumb.jpg" width="244" align="left" border="0" /></a>Matlab is a very useful tool for doing a number of things and to a number of people especially researchers due to its very short development time. Having a command line driven interface however can be unlikable at times. Matlab however provides a great GUI interface and tolls to&#160; create the GUIs.</p>
<p>Here is a simple 4 step method to get you started with Matlab GUI.</p>
<p>&#160;</p>
<p>&#160;</p>
<p> <span id="more-24"></span>
<p>&#160;</p>
<p>I assume some background with other GUIs and Matlab.</p>
<p>We will create this Matlab GUI in 4 simple steps.</p>
<p><a href="http://tayyab.xenoglaux-solutions.com/wp-content/uploads/2009/04/image.png"><img title="image" style="border-top-width: 0px; display: inline; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" height="233" alt="image" src="http://tayyab.xenoglaux-solutions.com/wp-content/uploads/2009/04/image-thumb.png" width="244" border="0" /></a> </p>
<h3>Step 1: Creating a Blank GUI</h3>
<p>The Matlab GUI development tool is called GUIDE. To open this tool simply type ‘guide’ on the command window.</p>
<p><a href="http://tayyab.xenoglaux-solutions.com/wp-content/uploads/2009/04/image1.png"><img title="image" style="border-top-width: 0px; display: inline; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" height="379" alt="image" src="http://tayyab.xenoglaux-solutions.com/wp-content/uploads/2009/04/image-thumb1.png" width="644" border="0" /></a> </p>
<p>Select Blank GUI from the options on the left and click OK. A blank Matlab GUI (.fig file) is created.</p>
<p>Note: You can also set where to save this file by checking the ‘Save new figure as:’ check box.</p>
<h3>Step 2: Creating the Interface</h3>
<p>Creating the GUI interface is pretty simple, we have a controls toolbar from where you simply drag and drop onto your GUI.</p>
<p><a href="http://tayyab.xenoglaux-solutions.com/wp-content/uploads/2009/04/image2.png"><img title="image" style="border-top-width: 0px; display: inline; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" height="484" alt="image" src="http://tayyab.xenoglaux-solutions.com/wp-content/uploads/2009/04/image-thumb2.png" width="583" border="0" /></a> </p>
<p>I have added three edit boxes and a push button. The goal is to create a simple GUI based adder.</p>
<p>You can use the static text control to create labels for you text boxes and your GUI.</p>
<p><a href="http://tayyab.xenoglaux-solutions.com/wp-content/uploads/2009/04/image3.png"><img title="image" style="border-top-width: 0px; display: inline; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" height="484" alt="image" src="http://tayyab.xenoglaux-solutions.com/wp-content/uploads/2009/04/image-thumb3.png" width="583" border="0" /></a></p>
<p>To change the color and text on the controls, use the property inspector. The two main properties that would concern us for now are ‘String’ and ‘Tag’. ‘String’ is the display text of the control where as ‘Tag’ is the handle of the control accessible from the code. </p>
<p><a href="http://tayyab.xenoglaux-solutions.com/wp-content/uploads/2009/04/image4.png"><img title="image" style="border-top-width: 0px; display: inline; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" height="484" alt="image" src="http://tayyab.xenoglaux-solutions.com/wp-content/uploads/2009/04/image-thumb4.png" width="244" border="0" /></a> </p>
<h3>Step 3: Retrieving and Validating Data</h3>
<p>Every control has a Callback function which is called when the control is used. First we set the Callbacks for the two edit boxes and validate data.</p>
<p><a href="http://tayyab.xenoglaux-solutions.com/wp-content/uploads/2009/04/image5.png"><img title="image" style="border-top-width: 0px; display: inline; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" height="484" alt="image" src="http://tayyab.xenoglaux-solutions.com/wp-content/uploads/2009/04/image-thumb5.png" width="581" border="0" /></a> </p>
<div id="codeSnippetWrapper" style="border-right: silver 1px solid; padding-right: 4px; border-top: silver 1px solid; padding-left: 4px; font-size: 8pt; padding-bottom: 4px; margin: 20px 0px 10px; overflow: auto; border-left: silver 1px solid; width: 97.5%; cursor: text; direction: ltr; max-height: 200px; line-height: 12pt; padding-top: 4px; border-bottom: silver 1px solid; font-family: &#39;Courier New&#39;, courier, monospace; background-color: #f4f4f4; text-align: left">
<div id="codeSnippet" style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; text-align: left; border-bottom-style: none">
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; text-align: left; border-bottom-style: none"><span id="lnum1" style="color: #606060">   1:</span> <span style="color: #0000ff">function</span> edit_num1_Callback(hObject, eventdata, handles)</pre>
<p><!--CRLF--></p>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; text-align: left; border-bottom-style: none"><span id="lnum2" style="color: #606060">   2:</span> % hObject handle to edit_num1 (see GCBO)</pre>
<p><!--CRLF--></p>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; text-align: left; border-bottom-style: none"><span id="lnum3" style="color: #606060">   3:</span> % eventdata reserved - to be defined <span style="color: #0000ff">in</span> a future version of MATLAB</pre>
<p><!--CRLF--></p>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; text-align: left; border-bottom-style: none"><span id="lnum4" style="color: #606060">   4:</span> % handles structure with handles and user data (see GUIDATA)</pre>
<p><!--CRLF--></p>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; text-align: left; border-bottom-style: none"><span id="lnum5" style="color: #606060">   5:</span> % Hints: get(hObject,<span style="color: #006080">'String'</span>) returns contents of edit_num1 as text</pre>
<p><!--CRLF--></p>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; text-align: left; border-bottom-style: none"><span id="lnum6" style="color: #606060">   6:</span> % str2double(get(hObject,<span style="color: #006080">'String'</span>)) returns contents of edit_num1 as a double</pre>
<p><!--CRLF--></div>
</div>
<p>Now we wish to retrieve the data contained in edit_num1 (the first of the two edit boxes).</p>
<div id="codeSnippetWrapper" style="border-right: silver 1px solid; padding-right: 4px; border-top: silver 1px solid; padding-left: 4px; font-size: 8pt; padding-bottom: 4px; margin: 20px 0px 10px; overflow: auto; border-left: silver 1px solid; width: 97.5%; cursor: text; direction: ltr; max-height: 200px; line-height: 12pt; padding-top: 4px; border-bottom: silver 1px solid; font-family: &#39;Courier New&#39;, courier, monospace; height: 139px; background-color: #f4f4f4; text-align: left">
<div id="codeSnippet" style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; text-align: left; border-bottom-style: none">
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; text-align: left; border-bottom-style: none"><span id="lnum1" style="color: #606060">   1:</span> %get the String data from the control</pre>
<p><!--CRLF--></p>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; text-align: left; border-bottom-style: none"><span id="lnum2" style="color: #606060">   2:</span> % and check <span style="color: #0000ff">if</span> it is empty</pre>
<p><!--CRLF--></p>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; text-align: left; border-bottom-style: none"><span id="lnum3" style="color: #606060">   3:</span> a = str2double(get(hObject, <span style="color: #006080">'String'</span>));</pre>
<p><!--CRLF--></p>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; text-align: left; border-bottom-style: none"><span id="lnum4" style="color: #606060">   4:</span> <span style="color: #0000ff">if</span> (isempty(a))</pre>
<p><!--CRLF--></p>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; text-align: left; border-bottom-style: none"><span id="lnum5" style="color: #606060">   5:</span> %     <span style="color: #0000ff">if</span> data is empty set the data to 0</pre>
<p><!--CRLF--></p>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; text-align: left; border-bottom-style: none"><span id="lnum6" style="color: #606060">   6:</span>     set(handles,<span style="color: #006080">'String'</span> ,<span style="color: #006080">'0'</span>);</pre>
<p><!--CRLF--></p>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; text-align: left; border-bottom-style: none"><span id="lnum7" style="color: #606060">   7:</span> <span style="color: #0000ff">end</span></pre>
<p><!--CRLF--></p>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; text-align: left; border-bottom-style: none"><span id="lnum8" style="color: #606060">   8:</span> guidata(hObject, handles);</pre>
<p><!--CRLF--></div>
</div>
<p>We add similar code for the edit_num2.</p>
<h3>Step 4: Adding functionality</h3>
<p>First create the call back for the push button.</p>
<p>In the push button call back add the following code.</p>
<div id="codeSnippetWrapper" style="border-right: silver 1px solid; padding-right: 4px; border-top: silver 1px solid; padding-left: 4px; font-size: 8pt; padding-bottom: 4px; margin: 20px 0px 10px; overflow: auto; border-left: silver 1px solid; width: 97.5%; cursor: text; direction: ltr; max-height: 200px; line-height: 12pt; padding-top: 4px; border-bottom: silver 1px solid; font-family: &#39;Courier New&#39;, courier, monospace; background-color: #f4f4f4; text-align: left">
<div id="codeSnippet" style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; text-align: left; border-bottom-style: none">
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; text-align: left; border-bottom-style: none"><span id="lnum1" style="color: #606060">   1:</span> % get the data of both edit boxes</pre>
<p><!--CRLF--></p>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; text-align: left; border-bottom-style: none"><span id="lnum2" style="color: #606060">   2:</span> a = str2double(get(handles.edit_num1, <span style="color: #006080">'String'</span>));</pre>
<p><!--CRLF--></p>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; text-align: left; border-bottom-style: none"><span id="lnum3" style="color: #606060">   3:</span> b = str2double(get(handles.edit_num2, <span style="color: #006080">'String'</span>));</pre>
<p><!--CRLF--></p>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; text-align: left; border-bottom-style: none"><span id="lnum4" style="color: #606060">   4:</span> % add the two</pre>
<p><!--CRLF--></p>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; text-align: left; border-bottom-style: none"><span id="lnum5" style="color: #606060">   5:</span> c = a+b;</pre>
<p><!--CRLF--></p>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; text-align: left; border-bottom-style: none"><span id="lnum6" style="color: #606060">   6:</span> % set the data into the answer edit</pre>
<p><!--CRLF--></p>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; text-align: left; border-bottom-style: none"><span id="lnum7" style="color: #606060">   7:</span> set(handles.edit_ans, <span style="color: #006080">'String'</span>, num2str(c) );</pre>
<p><!--CRLF--></p>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; text-align: left; border-bottom-style: none"><span id="lnum8" style="color: #606060">   8:</span> guidata(hObject, handles);</pre>
<p><!--CRLF--></div>
</div>
<p>Note how we get information from the edit boxes. Also note that we have to call <font face="Courier">guidata(hObject, handles); </font><font face="tre">to make the updates to the edit_ans useful.</font></p>
<p>I hope you find this tutorial useful, please feel free to leave your comments and questions.</p>
<p class="facebook"><a href="http://www.facebook.com/share.php?u=http://tayyab.xenoglaux-solutions.com/2009/04/06/creating-matlab-gui-the-basics/" target="_blank"><img src="http://tayyab.xenoglaux-solutions.com/wp-content/plugins/add-to-facebook-plugin/facebook_share_icon.gif" alt="Share on Facebook" title="Share on Facebook" /></a><a href="http://www.facebook.com/share.php?u=http://tayyab.xenoglaux-solutions.com/2009/04/06/creating-matlab-gui-the-basics/" target="_blank" title="Share on Facebook">Share on Facebook</a></p>]]></content:encoded>
			<wfw:commentRss>http://tayyab.xenoglaux-solutions.com/2009/04/06/creating-matlab-gui-the-basics/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
	</channel>
</rss>

