<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" media="screen" href="/~d/styles/rss2full.xsl"?><?xml-stylesheet type="text/css" media="screen" href="http://feeds.feedburner.com/~d/styles/itemcontent.css"?><rss 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:feedburner="http://rssnamespace.org/feedburner/ext/1.0" version="2.0">

<channel>
	<title>blinkdagger » MATLAB</title>
	
	<link>http://blinkdagger.com</link>
	<description>an Engineering and MATLAB blog</description>
	<pubDate>Wed, 09 Sep 2009 16:45:30 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.7.1</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="self" href="http://feeds.feedburner.com/blinkdaggerMatlab" type="application/rss+xml" /><atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="hub" href="http://pubsubhubbub.appspot.com" /><item>
		<title>The End of Blinkdagger? . . . . Possibly</title>
		<link>http://feedproxy.google.com/~r/blinkdaggerMatlab/~3/s4BvyaR2D5I/</link>
		<comments>http://blinkdagger.com/matlab/the-end-of-blinkdagger-possibly/#comments</comments>
		<pubDate>Mon, 06 Jul 2009 15:25:36 +0000</pubDate>
		<dc:creator>Quan Quach</dc:creator>
		
		<category><![CDATA[MATLAB]]></category>

		<guid isPermaLink="false">http://blinkdagger.com/?p=1923</guid>
		<description><![CDATA[Hello Everyone.  As many of you have probably noticed, Blinkdagger has not been posting with as much regularity.  I would like to announce that this is probably going to be one of the last posts you will see at Blinkdagger.  There are no plans to continue posting MATLAB tutorials in the immediate [...]<p>The post is the sole property of blinkdagger.com.  Please do no repost or distribute without consent.</p>
<p><a href="http://blinkdagger.com/matlab/the-end-of-blinkdagger-possibly/">The End of Blinkdagger? . . . . Possibly</a></p>
]]></description>
			<content:encoded><![CDATA[
<p><a href="http://feedads.g.doubleclick.net/~a/55OKBWOskI2Ib3AOw0LHbtUc6cs/0/da"><img src="http://feedads.g.doubleclick.net/~a/55OKBWOskI2Ib3AOw0LHbtUc6cs/0/di" border="0" ismap="true"></img></a><br/>
<a href="http://feedads.g.doubleclick.net/~a/55OKBWOskI2Ib3AOw0LHbtUc6cs/1/da"><img src="http://feedads.g.doubleclick.net/~a/55OKBWOskI2Ib3AOw0LHbtUc6cs/1/di" border="0" ismap="true"></img></a></p><p>Hello Everyone.  As many of you have probably noticed, Blinkdagger has not been posting with as much regularity.  I would like to announce that this is probably going to be one of the last posts you will see at Blinkdagger.  There are no plans to continue posting MATLAB tutorials in the immediate future.</p>
<p>At the time of this post, there are over 800 RSS subscribers, and over 2500 visitors a day on average.  I started this website with Daniel from nothing and have developed it to an impressive level.  A lot of you are probably wondering &#8220;Why?&#8221;  I will do the best I can to explain the circumstances that have led to this decision.</p>
<h2>Daniel Sutoyo Accepts a Position at The MathWorks</h2>
<p>If there&#8217;s one good thing that has emerged from this website, it&#8217;s the fact that Daniel was able to obtain a position at The MathWorks.  Unfortunately, as soon as Daniel became an employee of The MathWorks, there was a conflict of interest in being affiliated with this website.  Originally, no one knew what to expect from this union.  When we were going through the interview process, we were told that we would be able to maintain this blog while simultaneously working at The MathWorks.  As it turns out, things would not be so simple. </p>
<p>After several meetings with The MathWorks legal team, it was determined that Daniel would be unable to contribute anything MATLAB related to this website.  Thus, that essentially ended Daniel&#8217;s participation here at Blinkdagger as everything on this website is basically MATLAB related.  Since this site took a great deal of effort to maintain, we found it difficult to continue on since one half of the team was removed from the equation.  We had some big plans moving forward, but in the end we found that working around the legal ramifications would prove insurmountable, and that our time would be better spent on other projects.  </p>
<h2>The MathWorks Support - Or Lack of </h2>
<p>One of the things that bothered me is that The MathWorks was not very supportive of the efforts over here at Blinkdagger.  Over the course of this website&#8217;s life, the site provided over 100+ informative tutorials on how to use MATLAB to create GUIs, how to create plots, use particular functions, and various other tips and tricks on learning MATLAB.  </p>
<p>I believe that Blinkdagger has created and maintained a valuable MATLAB resource; this is corroborated with hundreds if not thousands of positive feedback through the many comments that are received on a daily basis.  Many months ago, I had queried The MathWorks on obtaining a personal license for MATLAB.  Since this website provides many useful tutorials, it did not seem like a stretch by any means to make such a request.  I was basically told that The MathWorks would be unable to provide such a license due to some legal restriction. If they were to provide such a license, they would then have to start monitoring the blog content, etc.   To be honest, I found this quite frustrating.  The way I saw it, it would be a win/win situation for both parties at hand.  Unfortunately, the request was never granted.  </p>
<p>Additionally, I felt that The MathWorks could have done a better job promoting and assisting websites like this one in order to cultivate an environment wherein more bloggers would be compelled to contribute to the MATLAB community.  The MathWorks have created a great internal community at MATLAB central, but the potential for growth could be so much more and over a broader spectrum if they provided more support and incentive.  In my opinion, it would be to the advantage of The MathWorks if there were more blogs like Blinkdagger out there, helping other users learn how to use this great tool.  In fact, as of now, Blinkdagger is probably the largest external MATLAB website/blog.   While The MathWorks have some internal blogs, those are homegrown and provide an entirely different flavor.  The potential for external blogs is, in my opinion, much greater and provides a different platform wherein MATLAB can thrive and flourish. </p>
<h2>Final Thanks</h2>
<p>Finally, I would like to thank everyone who helped contribute to this site.  Specifically, I would like to thank Rob Slazas, Sol Lederman, and Zane Montgomery, for their help throughout the last two years.  Finally, I would like to <strong>thank everyone who was kind enough to leave an encouraging comment.</strong>  The comments Blinkdagger received were the best part about maintaining this website, as it was concrete proof and positive reinforcement that Blinkdagger was helping others understand and use MATLAB.  The reason Blinkdagger continued on for so long was because of the kind comments that were received.</p>
<h2> In Closing </h2>
<p>This blog has been something that I have poured a lot of work into, and it is difficult to leave it as is.  If anyone is serious in contributing to the blog or wants to see Blinkdagger continue, please leave a comment below or send a memo through the contact form.  For now, there will be no more tutorials, but the website will continue to be active until the end of the hosting contract (which may or may not be renewed).  </p>
<p>The post is the sole property of blinkdagger.com.  Please do no repost or distribute without consent.</p>
<p><a href="http://blinkdagger.com/matlab/the-end-of-blinkdagger-possibly/">The End of Blinkdagger? . . . . Possibly</a></p>
<img src="http://feeds.feedburner.com/~r/blinkdaggerMatlab/~4/s4BvyaR2D5I" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://blinkdagger.com/matlab/the-end-of-blinkdagger-possibly/feed/</wfw:commentRss>
		<feedburner:origLink>http://blinkdagger.com/matlab/the-end-of-blinkdagger-possibly/</feedburner:origLink></item>
		<item>
		<title>MATLAB - Global Variables</title>
		<link>http://feedproxy.google.com/~r/blinkdaggerMatlab/~3/c0AS2SO_y44/</link>
		<comments>http://blinkdagger.com/matlab/matlab-global-variables/#comments</comments>
		<pubDate>Tue, 30 Jun 2009 15:46:39 +0000</pubDate>
		<dc:creator>Zane Montgomery</dc:creator>
		
		<category><![CDATA[GUI]]></category>

		<category><![CDATA[MATLAB]]></category>

		<guid isPermaLink="false">http://blinkdagger.com/?p=1853</guid>
		<description><![CDATA[How do global variables differ from regular (local) variables?
Each function in MATLAB contains a set of variables specific to that function.  Even in the same .m file, you don&#8217;t have (direct) access to variables created in other functions within the file.  Global variables give you the ability to create/change a variable in one function and have [...]<p>The post is the sole property of blinkdagger.com.  Please do no repost or distribute without consent.</p>
<p><a href="http://blinkdagger.com/matlab/matlab-global-variables/">MATLAB - Global Variables</a></p>
]]></description>
			<content:encoded><![CDATA[
<p><a href="http://feedads.g.doubleclick.net/~a/qWGdAhZ32oP5VMqvfetHfRkVsHA/0/da"><img src="http://feedads.g.doubleclick.net/~a/qWGdAhZ32oP5VMqvfetHfRkVsHA/0/di" border="0" ismap="true"></img></a><br/>
<a href="http://feedads.g.doubleclick.net/~a/qWGdAhZ32oP5VMqvfetHfRkVsHA/1/da"><img src="http://feedads.g.doubleclick.net/~a/qWGdAhZ32oP5VMqvfetHfRkVsHA/1/di" border="0" ismap="true"></img></a></p><h2><img src="http://www.blinkdagger.com/tutorials/matlab/matlab-icon.jpg" alt="Matlab Logo" hspace="10" align="left" />How do global variables differ from regular (local) variables?</h2>
<p>Each function in MATLAB contains a set of variables specific to that function.  Even in the same .m file, you don&#8217;t have (direct) access to variables created in other functions within the file.  Global variables give you the ability to create/change a variable in one function and have that updated variable accessible elsewhere.  This post will discuss two methods for handling (no pun intended) global variables, one of which is perfectly integrated into Graphical User Interfaces (GUIs).</p>
<h2>METHOD 1: global VARIABLE</h2>
<p>The first (non-GUI) way to create a global variable is to use the function &#8216;global&#8217;.  Create the global variables X, Y, and Z with the command:</p>
<pre class="codeinput"><span class="keyword">global </span> X Y Z</pre>
<p>The &#8216;global&#8217; function needs to be called in <em>each </em>separate function (usually in the beginning) where the variables will be called.   Stylistically, the variable names are usually longer names and all in CAPS to indicate global variables within the functions.  The documented example in the MATLAB helps shows this pretty well:</p>
<pre class="programlisting">
<pre class="codeinput"><span class="keyword">function</span> tic
<span class="keyword">global</span> TICTOC <span class="comment">%define/incorporate global variable at start of function</span>
TICTOC = clock;

<span class="keyword">function</span> t = toc
<span class="keyword">global</span> TICTOC <span class="comment">%accesses variable TICTOC (or creates it if TICTOC is undefined)</span>
<span class="keyword">if</span> nargout &lt; 1
    elapsed_time = etime(clock, TICTOC)
<span class="keyword">else</span>
    t = etime(clock, TICTOC);
<span class="keyword">end</span></pre>
</pre>
<p>Many hard-core coders prefer to <em>avoid</em> using &#8216;global&#8217; except for constants.  The reason behind this is because it&#8217;s generally considered poor form to lock up a variable name (See Steve L&#8217;s comment below for another reason!).  While this won&#8217;t matter for smaller programs and functions, when the files get to be many hundreds (or thousands or millions) of lines long, it can be very difficult to keep track of all of the global variables and to remember to call all the necessary variables at the start of each function.  The great thing about GUIs is that they already have a built-in global structure to deal with all of your global variables: the handles.  The handles structure is an input (and therefore accessible) to every function in the GUI, making it perfectly capable doing everything the &#8216;global&#8217; command can.  In fact, you shouldn&#8217;t <em>ever</em> have to use &#8216;global&#8217; command when designing a GUI because the handles structure does the job so well.  GUIs and &#8216;global&#8217; don&#8217;t mix kids!</p>
<h2>METHOD 2: handles.variable</h2>
<p>As you may have seen from many of the blinkdagger GUI tutorials, the handles structure is an extremely useful method to manipulate GUI boxes/buttons/tools.  But the tool data are all just stored variables that can be accessed anywhere within the GUI (aka global variables!).  Since we don&#8217;t need to edit any &#8216;property&#8217; of the handles structure (e.g. handles.static_text, &#8216;String&#8217;), we don&#8217;t need to use the &#8216;get&#8217;/&#8217;set&#8217; commands.  Creating the global variable is as easy as saying:</p>
<pre class="codeinput">handles.x = 42;
<span class="comment">%And of course, don't forget to update your handles structure:</span>
guidata(hObject, handles);</pre>
<p>handles.x is now an independent variable and note that it has no relation to the local variable x.</p>
<pre class="codeinput">x = 43;</pre>
<p>is a completely valid command in the same function that would not overwrite your global variable &#8216;handles.x&#8217;.</p>
<p>Remember, these variables can range from constants (e.g. 12) to strings (e.g. &#8216;Hello World&#8217;) to structures, cells, and arrays of constants/strings.</p>
<p>Hopefully you can see the usefullness of global variables and will use them (properly!) in your coding adventures.</p>
<p>The post is the sole property of blinkdagger.com.  Please do no repost or distribute without consent.</p>
<p><a href="http://blinkdagger.com/matlab/matlab-global-variables/">MATLAB - Global Variables</a></p>
<img src="http://feeds.feedburner.com/~r/blinkdaggerMatlab/~4/c0AS2SO_y44" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://blinkdagger.com/matlab/matlab-global-variables/feed/</wfw:commentRss>
		<feedburner:origLink>http://blinkdagger.com/matlab/matlab-global-variables/</feedburner:origLink></item>
		<item>
		<title>MATLAB GUI Tutorial - UITABLE Part 2, How To Access Table Data</title>
		<link>http://feedproxy.google.com/~r/blinkdaggerMatlab/~3/C3J5keCxKVs/</link>
		<comments>http://blinkdagger.com/matlab/matlab-gui-tutorial-uitable-part-2-how-to-access-table-data/#comments</comments>
		<pubDate>Sun, 31 May 2009 09:13:18 +0000</pubDate>
		<dc:creator>Quan Quach</dc:creator>
		
		<category><![CDATA[Data Processing]]></category>

		<category><![CDATA[GUI]]></category>

		<category><![CDATA[MATLAB]]></category>

		<category><![CDATA[blinkdagger]]></category>

		<category><![CDATA[extract table data]]></category>

		<category><![CDATA[gui table]]></category>

		<category><![CDATA[manipulate data on table GUI]]></category>

		<category><![CDATA[MATLAB blog]]></category>

		<category><![CDATA[Matlab GUI]]></category>

		<category><![CDATA[MATLAB GUI Table]]></category>

		<category><![CDATA[MATLAB table]]></category>

		<category><![CDATA[read table data]]></category>

		<category><![CDATA[table]]></category>

		<category><![CDATA[uitable]]></category>

		<category><![CDATA[uitable component]]></category>

		<guid isPermaLink="false">http://blinkdagger.com/?p=1816</guid>
		<description><![CDATA[ Last time, we learned how to display data onto a table.  This time, we&#8217;re going to learn how to work with table data within a GUI framework.  For example, say you wanted to take the contents of the table manipulate the data.  This tutorial will explain how to do that, and [...]<p>The post is the sole property of blinkdagger.com.  Please do no repost or distribute without consent.</p>
<p><a href="http://blinkdagger.com/matlab/matlab-gui-tutorial-uitable-part-2-how-to-access-table-data/">MATLAB GUI Tutorial - UITABLE Part 2, How To Access Table Data</a></p>
]]></description>
			<content:encoded><![CDATA[
<p><a href="http://feedads.g.doubleclick.net/~a/s9Y7uln1PYzP1QeOQoCnD9nzVL4/0/da"><img src="http://feedads.g.doubleclick.net/~a/s9Y7uln1PYzP1QeOQoCnD9nzVL4/0/di" border="0" ismap="true"></img></a><br/>
<a href="http://feedads.g.doubleclick.net/~a/s9Y7uln1PYzP1QeOQoCnD9nzVL4/1/da"><img src="http://feedads.g.doubleclick.net/~a/s9Y7uln1PYzP1QeOQoCnD9nzVL4/1/di" border="0" ismap="true"></img></a></p><p><img src="http://www.blinkdagger.com/tutorials/matlab/matlab-icon.jpg" alt="Matlab Logo" hspace="10" align="left" /> Last time, we learned how to display data onto a table.  This time, we&#8217;re going to learn how to work with table data within a GUI framework.  For example, say you wanted to take the contents of the table manipulate the data.  This tutorial will explain how to do that, and much more.</p>
<p><img src="http://blinkdagger.com/tutorials/matlab/GUI/basic/uitable/part02/uitable_tutorial_02_07.png" alt="MATLAB UITABLE Tutorial 2" class="center" /></p>
<h2>Contents</h2>
<ul>
<li><a href="#1">Accessing Table Data within GUI Callbacks</a></li>
<li><a href="#2">Accessing only the Selected Data</a></li>
<li><a href="#4">Next Time</a></li>
<li><a href="#5">Links and Downloads</a></li>
</ul>
<h2>Accessing Table Data within GUI Callbacks<a name="1"></a></h2>
<p>Let&#8217;s say you have the following GUI:</p>
<p><img src="http://blinkdagger.com/tutorials/matlab/GUI/basic/uitable/part02/uitable_tutorial_02_01.png" alt="MATLAB UITABLE Tutorial 2" class="center" /></p>
<p>For simplicity sake, let&#8217;s assume that you would like to create a button that will add 3 to each of the entries of the table when the button is pressed.  How would you go about doing this?  It&#8217;s actually quite straightforward.  Let&#8217;s take a look at the callback for the add button:</p>
<pre class="codeinput">
<span class="keyword">function</span> add_pushbutton_Callback(hObject, eventdata, handles)
<span class="comment">% hObject    handle to add_pushbutton (see GCBO)</span>
<span class="comment">% eventdata  reserved - to be defined in a future version of MATLAB</span>
<span class="comment">% handles    structure with handles and user data (see GUIDATA)</span>

<span class="comment">%get the table data</span>
tableData = get(handles.uitable1,<span class="string">'data'</span>);

<span class="comment">%add 3 to the table</span>
tableData = tableData + 3;

<span class="comment">%update the table</span>
set(handles.uitable1,<span class="string">'data'</span>,tableData);
</pre>
<p>So now, when I press the &#8220;Add 3&#8243; button, it adds 3 to the table!  This is just a simple example to show how to extract the data from the UITABLE, and to perform an operation on it. </p>
<p><img src="http://blinkdagger.com/tutorials/matlab/GUI/basic/uitable/part02/uitable_tutorial_02_02.png" alt="MATLAB UITABLE Tutorial 2" class="center" /></p>
<h2>Accessing only the Selected Data<a name="2"></a></h2>
<p>Now, let&#8217;s up the difficulty level a bit.  Let&#8217;s say you selected a couple of cells that you want to sum, as shown in the image below  (You can hold onto the CTRL button while clicking on individual cells to select multiple cells).</p>
<p><img src="http://blinkdagger.com/tutorials/matlab/GUI/basic/uitable/part02/uitable_tutorial_02_03.png" alt="MATLAB UITABLE Tutorial 2" class="center" /></p>
<p>How would you go about doing this?  Read on and all will be revealed.  </p>
<h2>Enabling CellSelectionCallback<a name="3"></a></h2>
<p>The first thing we need to do is to enable the Cell Selection Callback.  But first, why are we doing this?  <strong>Enabling this callback will allow us to keep track of what cells are being selected on the table</strong>.  You can do this by bringing up the Property Inspector for the UITABLE, and then clicking the following icon as shown in the image below.  </p>
<p><img src="http://blinkdagger.com/tutorials/matlab/GUI/basic/uitable/part02/uitable_tutorial_02_04.png" alt="MATLAB UITABLE Tutorial 2" class="center" /></p>
<p>If you did it correctly, your m-file should have been updated to include the following:</p>
<pre class="codeinput">
<span class="comment">% --- Executes when selected cell(s) is changed in uitable1.</span>
<span class="keyword">function</span> uitable1_CellSelectionCallback(hObject, eventdata, handles)
<span class="comment">% hObject    handle to uitable1 (see GCBO)</span>
<span class="comment">% eventdata  structure with the following fields (see UITABLE)</span>
<span class="comment">%	Indices: row and column indices of the cell(s) currently selecteds</span>
<span class="comment">% handles    structure with handles and user data (see GUIDATA)</span>
</pre>
<p>In addition, the CellSelectionCallback field should now be populated as shown in the image below:</p>
<p><img src="http://blinkdagger.com/tutorials/matlab/GUI/basic/uitable/part02/uitable_tutorial_02_05.png" alt="MATLAB UITABLE Tutorial 2" class="center" /></p>
<h2>Adding the Necessary Code<a name="3"></a></h2>
<p>First, let&#8217;s create and initialize a variable to hold the table cell selection information.  We will call this handles.selectedCells, and initialize it in the opening function.</p>
<pre class="codeinput">
<span class="comment">% --- Executes just before uitable_tutorial_02 is made visible.</span>
<span class="keyword">function</span> uitable_tutorial_02_OpeningFcn(hObject, eventdata, handles, varargin)
<span class="comment">% This function has no output args, see OutputFcn.</span>
<span class="comment">% hObject    handle to figure</span>
<span class="comment">% eventdata  reserved - to be defined in a future version of MATLAB</span>
<span class="comment">% handles    structure with handles and user data (see GUIDATA)</span>
<span class="comment">% varargin   command line arguments to uitable_tutorial_02 (see VARARGIN)</span>

<span class="comment">%initialize this variable</span>
handles.selectedCells = [];
</pre>
<p>Next, we go to the uitable1_CellSelectionCallback, which is the callback that we just enabled.</p>
<pre class="codeinput">
<span class="comment">% --- Executes when selected cell(s) is changed in uitable1.</span>
<span class="keyword">function</span> uitable1_CellSelectionCallback(hObject, eventdata, handles)
<span class="comment">% hObject    handle to uitable1 (see GCBO)</span>
<span class="comment">% eventdata  structure with the following fields (see UITABLE)</span>
<span class="comment">%	Indices: row and column indices of the cell(s) currently selecteds</span>
<span class="comment">% handles    structure with handles and user data (see GUIDATA)</span>

<span class="comment">%every time the cell selection changes, we update this data</span>
<span class="comment">%eventdata stores the indices of the selected cells</span>
handles.selectedCells = eventdata.Indices;

<span class="comment">%update the gui data</span>
guidata(hObject, handles);
</pre>
<h2>Adding the Selected Numbers Together<a name="4"></a></h2>
<p>First, we&#8217;re going to add another button and a static text component to display the sum.  The modified GUI looks like this:</p>
<p><img src="http://blinkdagger.com/tutorials/matlab/GUI/basic/uitable/part02/uitable_tutorial_02_06.png" alt="MATLAB UITABLE Tutorial 2" class="center" /></p>
<p>Now, we need to write the callback for the button we just added:</p>
<pre class="codeinput">
<span class="comment">% --- Executes on button press in sumNumbers_pushbutton.</span>
<span class="keyword">function</span> sumNumbers_pushbutton_Callback(hObject, eventdata, handles)
<span class="comment">% hObject    handle to sumNumbers_pushbutton (see GCBO)</span>
<span class="comment">% eventdata  reserved - to be defined in a future version of MATLAB</span>
<span class="comment">% handles    structure with handles and user data (see GUIDATA)</span>

<span class="comment">%get the number of rows and columns</span>
[rows,columns] = size(handles.selectedCells);

<span class="comment">%get the data from the UITABLE</span>
tableData = get(handles.uitable1,<span class="string">'data'</span>);

<span class="comment">%initialize the sum</span>
sum = 0;

<span class="comment">%loop through each selected cell and keep a running sum</span>
<span class="comment">%can anyone thing of a better way to do this?</span>
<span class="keyword">for</span> x=1:rows
    sum = sum +tableData(tableIndices(x,1),tableIndices(x,2));
<span class="keyword">end</span>

<span class="comment">%display the sum on the GUI</span>
set(handles.sum_text,<span class="string">'String'</span>,num2str(sum))
</pre>
<p>And there you have it, now you can select any number of cells, and then sum up the value of the contents!</p>
<p><img src="http://blinkdagger.com/tutorials/matlab/GUI/basic/uitable/part02/uitable_tutorial_02_07.png" alt="MATLAB UITABLE Tutorial 2" class="center" /></p>
<h2>Next Time<a name="5"></a></h2>
<p>Next time, we&#8217;re going to talk about some of the cool features of the UITABLE that we have not yet discussed, including different data types within the UITABLE.</p>
<h2>Links and Downloads<a name="6"></a></h2>
<p><a href="http://blinkdagger.com/tutorials/matlab/GUI/basic/uitable/part02/uitable_tutorial_02.zip">Download Source Files </a><br />
<a href="http://www.mathworks.com/access/helpdesk/help/techdoc/index.html?/access/helpdesk/help/techdoc/ref/uitable.html">The MathWorks Documentation for UITABLE</a><br />
<a href="http://blogs.mathworks.com/desktop/2008/06/02/tables-in-matlab-with-uitable/">Cool Things You can do with UITABLE</a><br />
<a href="http://blogs.mathworks.com/videos/2009/01/29/exploring-uitable-properties/">Doug&#8217;s Video on UITABLE</a></p>
<p>The post is the sole property of blinkdagger.com.  Please do no repost or distribute without consent.</p>
<p><a href="http://blinkdagger.com/matlab/matlab-gui-tutorial-uitable-part-2-how-to-access-table-data/">MATLAB GUI Tutorial - UITABLE Part 2, How To Access Table Data</a></p>
<img src="http://feeds.feedburner.com/~r/blinkdaggerMatlab/~4/C3J5keCxKVs" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://blinkdagger.com/matlab/matlab-gui-tutorial-uitable-part-2-how-to-access-table-data/feed/</wfw:commentRss>
		<feedburner:origLink>http://blinkdagger.com/matlab/matlab-gui-tutorial-uitable-part-2-how-to-access-table-data/</feedburner:origLink></item>
		<item>
		<title>MATLAB GUI Tutorial - UITABLE Part 1, How to Display Data</title>
		<link>http://feedproxy.google.com/~r/blinkdaggerMatlab/~3/PGIJ9ikPpkc/</link>
		<comments>http://blinkdagger.com/matlab/matlab-gui-tutorial-uitable-part-1-how-to-display-data/#comments</comments>
		<pubDate>Wed, 27 May 2009 08:36:02 +0000</pubDate>
		<dc:creator>Quan Quach</dc:creator>
		
		<category><![CDATA[Data Processing]]></category>

		<category><![CDATA[GUI]]></category>

		<category><![CDATA[MATLAB]]></category>

		<category><![CDATA[blinkdagger]]></category>

		<category><![CDATA[display data on table GUI]]></category>

		<category><![CDATA[gui table]]></category>

		<category><![CDATA[MATLAB blog]]></category>

		<category><![CDATA[Matlab GUI]]></category>

		<category><![CDATA[MATLAB GUI Table]]></category>

		<category><![CDATA[MATLAB table]]></category>

		<category><![CDATA[table]]></category>

		<category><![CDATA[uitable]]></category>

		<category><![CDATA[uitable component]]></category>

		<guid isPermaLink="false">http://blinkdagger.com/?p=1813</guid>
		<description><![CDATA[ With the release of MATLAB 2008b, you are now able to add tables to a GUI.  In the past, there was no easy way to display your data in tabular form.  With the UITABLE component, displaying your data in tabular form is easy, and most importantly, looks great!  

Contents

Adding a Table [...]<p>The post is the sole property of blinkdagger.com.  Please do no repost or distribute without consent.</p>
<p><a href="http://blinkdagger.com/matlab/matlab-gui-tutorial-uitable-part-1-how-to-display-data/">MATLAB GUI Tutorial - UITABLE Part 1, How to Display Data</a></p>
]]></description>
			<content:encoded><![CDATA[
<p><a href="http://feedads.g.doubleclick.net/~a/8c3IEH-6tTtNEeiTeM7HsS81boQ/0/da"><img src="http://feedads.g.doubleclick.net/~a/8c3IEH-6tTtNEeiTeM7HsS81boQ/0/di" border="0" ismap="true"></img></a><br/>
<a href="http://feedads.g.doubleclick.net/~a/8c3IEH-6tTtNEeiTeM7HsS81boQ/1/da"><img src="http://feedads.g.doubleclick.net/~a/8c3IEH-6tTtNEeiTeM7HsS81boQ/1/di" border="0" ismap="true"></img></a></p><p><img src="http://www.blinkdagger.com/tutorials/matlab/matlab-icon.jpg" alt="Matlab Logo" hspace="10" align="left" /> With the release of MATLAB 2008b, you are now able to add tables to a GUI.  In the past, there was no easy way to display your data in tabular form.  With the UITABLE component, displaying your data in tabular form is easy, and most importantly, looks great!  </p>
<p><img src="http://blinkdagger.com/tutorials/matlab/GUI/basic/uitable/part01/uitable_tutorial_01_06.png" alt="MATLAB UITABLE" class="center" /></p>
<h2>Contents</h2>
<ul>
<li><a href="#1">Adding a Table to Your GUI using GUIDE</a></li>
<li><a href="#2">Displaying Data on the Table</a></li>
<li><a href="#3">Adding Column and Row Labels </a></li>
<li><a href="#4">Modifying your Table through the m-file</a></li>
<li><a href="#5">Next Time</a></li>
<li><a href="#6">Links and Downloads</a></li>
</ul>
<h2>Adding a Table to Your GUI using GUIDE<a name="1"></a></h2>
<p>Within the GUIDE framework, you can add a table to your GUI using the following icon from the toolbar: <img src="http://blinkdagger.com/tutorials/matlab/GUI/basic/uitable/part01/uitable_icon.png" alt="MATLAB UITABLE icon" />.</p>
<p>Here&#8217;s what the GUI will look like within GUIDE:</p>
<p><img src="http://blinkdagger.com/tutorials/matlab/GUI/basic/uitable/part01/uitable_tutorial_01_01.png" alt="MATLAB UITABLE tutorial" class="center" /></p>
<h2>Displaying Data on the Table<a name="2"></a></h2>
<p>We are going to populate the UITABLE component with data by pushing the &#8220;Populate Table&#8221; button.  Thus, we&#8217;re going to need to add some code to the pushbutton&#8217;s callback.  In the populate_pushbutton callback, we use the following code:</p>
<pre class="codeinput">
<span class="comment">% --- Executes on button press in populate_pushbutton.</span>
<span class="keyword">function</span> populate_pushbutton_Callback(hObject, eventdata, handles)
<span class="comment">% hObject    handle to populate_pushbutton (see GCBO)</span>
<span class="comment">% eventdata  reserved - to be defined in a future version of MATLAB</span>
<span class="comment">% handles    structure with handles and user data (see GUIDATA)</span>

<span class="comment">%first, create a data matrix that has 5 columns, 4 rows</span>
myData = rand(5,4);

<span class="comment">%now populate the table with the above values</span>
set(handles.uitable1,<span class="string">'data'</span>,myData );
</pre>
<p>Now, let&#8217;s run the GUI and push the button!</p>
<p><img src="http://blinkdagger.com/tutorials/matlab/GUI/basic/uitable/part01/uitable_tutorial_01_02.png" alt="MATLAB UITABLE tutorial" class="center" /></p>
<p>A neat feature is that the table is smart enough to fill out the table according to the size of the data matrix that you feed it.  So if I had done the following instead:</p>
<pre class="codeinput">
myData = rand(100,100);
</pre>
<p>The table would incorporate the use of scroll bars, as shown below.   </p>
<p><img src="http://blinkdagger.com/tutorials/matlab/GUI/basic/uitable/part01/uitable_tutorial_01_02a.png" alt="MATLAB UITABLE tutorial" class="center" /></p>
<h2>Adding Column and Row Labels<a name="3"></a></h2>
<p>A good way to spruce up your table is to add row and column labels.  This helps differentiate your data and makes it easy to identify.  Within the GUIDE framework, we can modify the labels by first bringing up the Property Inspector for the UITABLE.  This can be done by double clicking the UITABLE component.  </p>
<p><img src="http://blinkdagger.com/tutorials/matlab/GUI/basic/uitable/part01/uitable_tutorial_01_07a.png" alt="Property Insepctor" class="center" /></p>
<p>Now, if you click on any of the fields in the above picture, it will bring up the Table Property Editor.  This is where you can add Row and Column labels.  For example:</p>
<p><img src="http://blinkdagger.com/tutorials/matlab/GUI/basic/uitable/part01/uitable_tutorial_01_03a.png" alt="Edit Row Labels" class="center" /></p>
<p>Make sure you click on the &#8220;Rows&#8221;, and that you select the &#8220;Show names entered below as the row headers&#8221; option.  Finally, you just need to modify the names.  Similarly, you can do the same for the columns.</p>
<p><img src="http://blinkdagger.com/tutorials/matlab/GUI/basic/uitable/part01/uitable_tutorial_01_04a.png" alt="MATLAB UITABLE tutorial" class="center" /></p>
<p>Once you&#8217;re done with that. you should see the following:</p>
<p><img src="http://blinkdagger.com/tutorials/matlab/GUI/basic/uitable/part01/uitable_tutorial_01_05a.png" alt="MATLAB UITABLE tutorial" class="center" /></p>
<p>And once you run your GUI, you can see the final result. A well labeled table that displays your data beautifully!</p>
<p><img src="http://blinkdagger.com/tutorials/matlab/GUI/basic/uitable/part01/uitable_tutorial_01_06.png" alt="MATLAB UITABLE" class="center" /></p>
<h2>Modifying your Table through the m-file<a name="4"></a></h2>
<p>Sometimes it&#8217;s easier to work from within the m-file framework, rather than the GUIDE framework.  We could have done exactly what we did above programmatically through the m-file.  In the opening function we could have done the following:</p>
<pre class="codeinput">
<span class="comment">%store the row headers into a cell array</span>
rowHeaders = {<span class="string">'Blink'</span>,<span class="string">'Dagger'</span>,<span class="string">'Loves'</span>,<span class="string">'MATLAB'</span>,<span class="string">'!!!!!!'</span>};

<span class="comment">%set the row labels</span>
set(handles.uitable1,<span class="string">'RowName'</span>,rowHeaders);

<span class="comment">%do the same for the column headers</span>
columnHeaders = {<span class="string">'Quan'</span>,<span class="string">'Daniel'</span>,<span class="string">'Rob'</span>,<span class="string">'Zane'</span>};
set(handles.uitable1,<span class="string">'ColumnName'</span>,columnHeaders);
</pre>
<p>In this example, we assumed that we knew the dimensions of our table.  If you don&#8217;t know the size of your table beforehand, then it can be difficult to apply data labels that are meaningful.  By working through the m-file, you obtain more flexibility since you won&#8217;t have to go back and modify the .fig file every time you want to make a change.  And if you are going to apply dynamic labeling, then working from the m-file is going to be much easier.</p>
<h2>Next Time<a name="5"></a></h2>
<p>Next time, we&#8217;re going to talk about how to work with manipulating the data within the table. </p>
<h2>Links and Downloads<a name="6"></a></h2>
<p><a href="http://blinkdagger.com/tutorials/matlab/GUI/basic/uitable/part01/uitable_tutorial_01.zip">Download Source Files </a><br />
<a href="http://www.mathworks.com/access/helpdesk/help/techdoc/index.html?/access/helpdesk/help/techdoc/ref/uitable.html">The MathWorks Documentation for UITABLE</a><br />
<a href="http://blogs.mathworks.com/desktop/2008/06/02/tables-in-matlab-with-uitable/">Cool Things You can do with UITABLE</a><br />
<a href="http://blogs.mathworks.com/videos/2009/01/29/exploring-uitable-properties/">Doug&#8217;s Video on UITABLE</a></p>
<p>The post is the sole property of blinkdagger.com.  Please do no repost or distribute without consent.</p>
<p><a href="http://blinkdagger.com/matlab/matlab-gui-tutorial-uitable-part-1-how-to-display-data/">MATLAB GUI Tutorial - UITABLE Part 1, How to Display Data</a></p>
<img src="http://feeds.feedburner.com/~r/blinkdaggerMatlab/~4/PGIJ9ikPpkc" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://blinkdagger.com/matlab/matlab-gui-tutorial-uitable-part-1-how-to-display-data/feed/</wfw:commentRss>
		<feedburner:origLink>http://blinkdagger.com/matlab/matlab-gui-tutorial-uitable-part-1-how-to-display-data/</feedburner:origLink></item>
		<item>
		<title>MATLAB - Data Mining in MATLAB</title>
		<link>http://feedproxy.google.com/~r/blinkdaggerMatlab/~3/yv9VytLuTdk/</link>
		<comments>http://blinkdagger.com/matlab/matlab-data-mining-in-matlab/#comments</comments>
		<pubDate>Mon, 18 May 2009 21:14:19 +0000</pubDate>
		<dc:creator>Quan Quach</dc:creator>
		
		<category><![CDATA[MATLAB]]></category>

		<category><![CDATA[blinkdagger]]></category>

		<category><![CDATA[daniel sutoyo]]></category>

		<category><![CDATA[Data Mining in MATLAB]]></category>

		<category><![CDATA[MATLAB blog]]></category>

		<category><![CDATA[quan quach]]></category>

		<category><![CDATA[will Dwinnel]]></category>

		<guid isPermaLink="false">http://blinkdagger.com/?p=1726</guid>
		<description><![CDATA[
Besides the internal blogs over at The MathWorks website, there are a few hidden gems out there that don&#8217;t get as much recognition.  One of these blogs is William Dwinnel&#8217;s MATLAB blog, Data Mining in MATLAB.  We&#8217;ve actually been aware of Will&#8217;s site for quite some time now.  In fact, he even [...]<p>The post is the sole property of blinkdagger.com.  Please do no repost or distribute without consent.</p>
<p><a href="http://blinkdagger.com/matlab/matlab-data-mining-in-matlab/">MATLAB - Data Mining in MATLAB</a></p>
]]></description>
			<content:encoded><![CDATA[
<p><a href="http://feedads.g.doubleclick.net/~a/H2sjyeFbz7gugcn3ek4UTf8sz0U/0/da"><img src="http://feedads.g.doubleclick.net/~a/H2sjyeFbz7gugcn3ek4UTf8sz0U/0/di" border="0" ismap="true"></img></a><br/>
<a href="http://feedads.g.doubleclick.net/~a/H2sjyeFbz7gugcn3ek4UTf8sz0U/1/da"><img src="http://feedads.g.doubleclick.net/~a/H2sjyeFbz7gugcn3ek4UTf8sz0U/1/di" border="0" ismap="true"></img></a></p><p><img src="/wp-content/uploads/2009/april/data_mining.png" alt="data_mining.png" title="data_mining.png" width="600" height="408" border="1" class="center"/></p>
<p>Besides the internal blogs over at The MathWorks website, there are a few hidden gems out there that don&#8217;t get as much recognition.  One of these blogs is William Dwinnel&#8217;s MATLAB blog, <a href="http://matlabdatamining.blogspot.com/">Data Mining in MATLAB</a>.  We&#8217;ve actually been aware of Will&#8217;s site for quite some time now.  In fact, he even wrote a guest post here at Blinkdagger a while back on the topic of <a href="http://blinkdagger.com/matlab/matlab-a-introduction-to-combinatorics">combinatorics</a>.  </p>
<h2>Why I Love to Data Mine</h2>
<p>One of the things that I enjoy about Will&#8217;s blog is that he covers a wide variety of topics.  One day you might see a post on <a href="http://blinkdagger.com/matlab/matlab-a-introduction-to-combinatorics">Monte Carlo</a>, and the next day you may see a post on <a href="http://matlabdatamining.blogspot.com/2009/02/parallel-programming-another-look.html">parallel computing</a> or <a href="http://matlabdatamining.blogspot.com/2009/04/introduction-to-conditional-entropy.html">conditional entropy</a>.  His simplistic style of writing makes for an easy read.  Although he doesn&#8217;t update too frequently, it&#8217;s still a good blog to keep your eye on.</p>
<p>The post is the sole property of blinkdagger.com.  Please do no repost or distribute without consent.</p>
<p><a href="http://blinkdagger.com/matlab/matlab-data-mining-in-matlab/">MATLAB - Data Mining in MATLAB</a></p>
<img src="http://feeds.feedburner.com/~r/blinkdaggerMatlab/~4/yv9VytLuTdk" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://blinkdagger.com/matlab/matlab-data-mining-in-matlab/feed/</wfw:commentRss>
		<feedburner:origLink>http://blinkdagger.com/matlab/matlab-data-mining-in-matlab/</feedburner:origLink></item>
	</channel>
</rss><!-- Dynamic Page Served (once) in 0.869 seconds --><!-- Cached page generated by WP-Super-Cache on 2009-11-21 17:12:50 -->
