<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet href="http://feeds.feedburner.com/~d/styles/rss2full.xsl" type="text/xsl" media="screen"?><?xml-stylesheet href="http://feeds.feedburner.com/~d/styles/itemcontent.css" type="text/css" media="screen"?><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:feedburner="http://rssnamespace.org/feedburner/ext/1.0" version="2.0">

<channel>
	<title>blinkdagger » MATLAB</title>
	
	<link>http://www.blinkdagger.com</link>
	<description>a MATLAB blog providing tutorials, guides, and more</description>
	<pubDate>Thu, 24 Jul 2008 02:59:28 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.6</generator>
	<language>en</language>
			<atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="self" href="http://feeds.feedburner.com/blinkdaggerMatlab" type="application/rss+xml" /><item>
		<title>MATLAB - Fourier Transforms with freqz</title>
		<link>http://feeds.feedburner.com/~r/blinkdaggerMatlab/~3/342127142/matlab-fourier-transform-with-freqz</link>
		<comments>http://www.blinkdagger.com/matlab/matlab-fourier-transform-with-freqz#comments</comments>
		<pubDate>Tue, 22 Jul 2008 02:33:54 +0000</pubDate>
		<dc:creator>Quan Quach</dc:creator>
		
		<category><![CDATA[MATLAB]]></category>

		<category><![CDATA[fourier]]></category>

		<category><![CDATA[fft]]></category>

		<category><![CDATA[fourier transform]]></category>

		<category><![CDATA[freqz]]></category>

		<category><![CDATA[MATLAB blog]]></category>

		<category><![CDATA[MATLAB tutorial]]></category>

		<guid isPermaLink="false">http://www.blinkdagger.com/?p=136</guid>
		<description><![CDATA[This is the fifth post in the blinkdagger signal processing series.
 One of the drawbacks of using the fft command is that it doesn&#8217;t give you any information on the frequency axis.  It&#8217;s up to the user to create the corresponding frequency vector in order to obtain a meaningful FFT result. In the previous [...]]]></description>
			<content:encoded><![CDATA[<p><em>This is the fifth post in the blinkdagger signal processing series.</em></p>
<p><img src="http://www.blinkdagger.com/tutorials/matlab/matlab-icon.jpg" align = "left" alt="Matlab Logo" hspace = "10"  /> One of the drawbacks of using the <code>fft</code> command is that it doesn&#8217;t give you any information on the frequency axis.  It&#8217;s up to the user to create the corresponding frequency vector in order to obtain a meaningful FFT result. In the previous post, we discussed how to properly create frequency vectors to correspond with your FFT data.</p>
<p>In this tutorial, we&#8217;ll explore a different method to obtain the Fourier Transform of a given signal using a nifty built in command: <code>freqz</code>. </p>
<ul>
<li><a href="#2">Example</a></li>
<li><a href="#3">Using the fft command</a></li>
<li><a href="#4">Using the freqz command</a></li>
<li><a href="#5">Two Sided Spectrum</a></li>
<li><a href="#6">Positive Frequencies Only</a></li>
<li><a href="#7">Defining Your Frequency Interval</a></li>
<li><a href="#8">Knowing your Limits</a></li>
<li><a href="#10">Conclusion</a></li>
</ul>
<h2 id="toc-example">Example<a name="2"></a></h2>
<p>Let&#8217;s use the following code to create an example signal.  The example signal is simply a sine wave with a fundamental frequency of 4 Hz.</p>
<pre class="codeinput">fo = 4;   <span class="comment">%frequency of the sine wave in Hz</span>
Fs = 100; <span class="comment">%sampling rate in Hz</span>
Ts = 1/Fs; <span class="comment">%sampling time interval</span>
t = 0:Ts:1-Ts; <span class="comment">%time vector</span>
n = length(t); <span class="comment">%number of samples, 100</span>
y = 2*sin(2*pi*fo*t); <span class="comment">%the sine curve</span>

<span class="comment">%plot the sine curve in the time domain</span>
sinePlot = figure;
plot(t,y)
xlabel(<span class="string">'time (seconds)'</span>, <span class="string">'FontWeight'</span>,<span class="string">'Bold'</span>)
ylabel(<span class="string">'y(t)'</span>, <span class="string">'FontWeight'</span>,<span class="string">'Bold'</span>)
title(<span class="string">'Sample Sine Wave'</span>, <span class="string">'FontWeight'</span>,<span class="string">'Bold'</span>)
set(sinePlot,<span class="string">'Position'</span>,[500,500,500,300])
set(sinePlot,<span class="string">'Color'</span>,[0.97 0.97 0.97])
grid
</pre>
<p><img vspace="5" hspace="5" src="tutorials/MATLAB/fourier/freqz/freqzTutorial_01.png" class="center" /><br />
<span id="more-136"></span></p>
<h2 id="toc-using-the-fft-command">Using the fft command<a name="3"></a></h2>
<p>As discussed in the Introductory FFT Tutorial, the fft command within MATLAB only returns one vector of data.  You should <a href="http://www.blinkdagger.com/matlab/matlab-introductory-fft-tutorial">read this fft tutorial</a> first if you are unfamiliar with using the <code>fft</code> command.  But basically, the <code>fft</code> command only takes in as input the y-data of your time-domain signal. Thus,             it only returns the output-data of the fourier transform, which is in complex form.</p>
<h2 id="toc-using-the-freqz-command">Using the freqz Command<a name="4"></a></h2>
<p>The freqz command is a pretty versatile command.  With this command, you can dictate what frequency range you want to be evaluated.  So for example, lets say that I wanted to only look at the range of -5 Hz to 16 Hz, with frequency increments of 1 Hz.</p>
<pre class="codeinput">freqzExample = figure;
freqRange = -25:1:16; <span class="comment">%create a frequency vector from -25 to 16</span>
freqzData = freqz(y,1,freqRange,Fs)/length(y);  <span class="comment">%get the fourier data</span>

stem(freqRange,abs(freqzData))
xlabel(<span class="string">'freq (Hz)'</span>, <span class="string">'FontWeight'</span>,<span class="string">'Bold'</span>)
ylabel(<span class="string">'Amplitude'</span>, <span class="string">'FontWeight'</span>,<span class="string">'Bold'</span>)
title(<span class="string">'Using the freqz command'</span>, <span class="string">'FontWeight'</span>,<span class="string">'Bold'</span>)
set(freqzExample,<span class="string">'Position'</span>,[500,500,500,300])
set(freqzExample,<span class="string">'Color'</span>,[0.97 0.97 0.97])
xlim([-25 16]); ylim([0 2]); <span class="comment">%set axes limits</span>
grid
</pre>
<p><img vspace="5" hspace="5" src="/tutorials/MATLAB/fourier/freqz/freqzTutorial_02.png" class="center" /> </p>
<h2 id="toc-two-sided-spectrum">Two Sided Spectrum<a name="5"></a></h2>
<p>If I wanted to do a two sided spectrum, I would have defined the frequency range in the following manner:</p>
<pre class="codeinput">twoSided = figure;
freqRange = -Fs/2:1:Fs/2; <span class="comment">%create a two sided spectrum</span>
freqzData = freqz(y,1,freqRange,Fs)/length(y);  <span class="comment">%get the fourier data</span>

stem(freqRange,abs(freqzData))
xlabel(<span class="string">'freq (Hz)'</span>, <span class="string">'FontWeight'</span>,<span class="string">'Bold'</span>)
ylabel(<span class="string">'Amplitude'</span>, <span class="string">'FontWeight'</span>,<span class="string">'Bold'</span>)
title(<span class="string">'Two Sided Spectrum'</span>, <span class="string">'FontWeight'</span>,<span class="string">'Bold'</span>)
set(twoSided,<span class="string">'Position'</span>,[500,500,530,300])
set(twoSided,<span class="string">'Color'</span>,[0.97 0.97 0.97])
xlim([-50 50]); ylim([0 2]); grid
</pre>
<p><img vspace="5" hspace="5" src="/tutorials/MATLAB/fourier/freqz/freqzTutorial_03.png" class="center" /> </p>
<h2 id="toc-positive-frequencies-only">Positive Frequencies Only<a name="6"></a></h2>
<p>If I only wanted to see a positive portion of the fourier transform:</p>
<pre class="codeinput">positiveFreq = figure;
freqRange = 0:1:Fs/2; <span class="comment">% create a frequency range over the positive frequencies</span>
freqzData = freqz(y,1,freqRange,Fs)/length(y);  <span class="comment">%get the fourier data</span>

stem(freqRange,abs(freqzData))
xlabel(<span class="string">'freq (Hz)'</span>, <span class="string">'FontWeight'</span>,<span class="string">'Bold'</span>)
ylabel(<span class="string">'Amplitude'</span>, <span class="string">'FontWeight'</span>,<span class="string">'Bold'</span>)
title(<span class="string">'Positive Frequencies'</span>, <span class="string">'FontWeight'</span>,<span class="string">'Bold'</span>)
set(positiveFreq,<span class="string">'Position'</span>,[500,500,500,300])
set(positiveFreq,<span class="string">'Color'</span>,[0.97 0.97 0.97])
ylim([0 2]); grid
</pre>
<p><img vspace="5" hspace="5" src="/tutorials/MATLAB/fourier/freqz/freqzTutorial_04.png" class="center" /> </p>
<h2 id="toc-defining-your-frequency-interval">Defining Your Frequency Interval<a name="7"></a></h2>
<p>In addition to defining my frequency limits, I can only define how fine or coarse I want my frequency interval to be.  In the following example, I&#8217;m going to increase the frequency resolution.  This means that the output data will have 5 times as many data points!  This can be very useful, as it can help you visualize your data better when you plot it. Read this <a href="http://www.blinkdagger.com/matlab/matlab-fft-and-zero-padding">tutorial on zero padding</a> if there&#8217;s any confusion here! </p>
<pre class="codeinput">frequencyInterval = figure;
freqRange = 0:0.2:Fs/2; <span class="comment">% frequency vector with increment of 0.2</span>
freqzData = freqz(y,1,freqRange,Fs)/length(y); <span class="comment">%get the fourier data</span>

stem(freqRange,abs(freqzData))
xlabel(<span class="string">'freq (Hz)'</span>, <span class="string">'FontWeight'</span>,<span class="string">'Bold'</span>)
ylabel(<span class="string">'Amplitude'</span>, <span class="string">'FontWeight'</span>,<span class="string">'Bold'</span>)
title(<span class="string">'Frequeny Interval Reduced'</span>, <span class="string">'FontWeight'</span>,<span class="string">'Bold'</span>)
set(frequencyInterval,<span class="string">'Position'</span>,[500,500,500,300])
set(frequencyInterval,<span class="string">'Color'</span>,[0.97 0.97 0.97])
ylim([0 2]); grid
</pre>
<p><img vspace="5" hspace="5" src="/tutorials/MATLAB/fourier/freqz/freqzTutorial_05.png" class="center" /> </p>
<h2 id="toc-knowing-your-limits">Knowing your Limits<a name="8"></a></h2>
<p>The frequency range of your data depends on the sampling rate, Fs.  If Fs = 100 Hz, then your spectrum will span from -50 Hz to 50 Hz.  What happens if you go outside this range?  Simply put, the information is repeated. Let&#8217;s see what happens when we  define a frequency range from -200 to 200.
</p>
<pre class="codeinput">freqRange = -200:1:200; <span class="comment">%create a frequency vector from -25 to 16</span>
freqzData = freqz(y,1,freqRange,Fs)/length(y);  <span class="comment">%get the fourier data</span>

freqzLimit = figure;
stem(freqRange,abs(freqzData))
xlabel(<span class="string">'freq (Hz)'</span>, <span class="string">'FontWeight'</span>,<span class="string">'Bold'</span>)
ylabel(<span class="string">'Amplitude'</span>, <span class="string">'FontWeight'</span>,<span class="string">'Bold'</span>)
title(<span class="string">'Using the freqz command'</span>, <span class="string">'FontWeight'</span>,<span class="string">'Bold'</span>)
set(freqzLimit,<span class="string">'Position'</span>,[500,500,500,300])
set(freqzLimit,<span class="string">'Color'</span>,[0.97 0.97 0.97])
ylim([0 2]); grid
</pre>
<p><img vspace="5" hspace="5" src="/tutorials/MATLAB/fourier/freqz/freqzTutorial_06.png" class="center" /> </p>
<p>As you can see, the same information is simply repeated so there is no need to define a frequency vector outside the range of -Fs/2 and Fs/2.</p>
<h2 id="toc-conclusion">Conclusion<a name="10"></a></h2>
<p>The freqz command is a versatile command which in my opinion, is easier to use than the fft command.  The ability to define your frequency axis is very helpful and flexible.  With this method, you don&#8217;t have to worry about zero padding; you can simply define a very fine frequeny interval to get a better spectral resolution.</p>
<p>a</p>
<p><a href="http://www.blinkdagger.com/matlab/matlab-fourier-transform-with-freqz">MATLAB - Fourier Transforms with freqz</a></p>
<img src="http://feeds.feedburner.com/~r/blinkdaggerMatlab/~4/342127142" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.blinkdagger.com/matlab/matlab-fourier-transform-with-freqz/feed</wfw:commentRss>
		<feedburner:origLink>http://www.blinkdagger.com/matlab/matlab-fourier-transform-with-freqz</feedburner:origLink></item>
		<item>
		<title>Descriptive Statistics - Parte Deux</title>
		<link>http://feeds.feedburner.com/~r/blinkdaggerMatlab/~3/337662767/descriptive-statistics-parte-deux</link>
		<comments>http://www.blinkdagger.com/matlab/descriptive-statistics-parte-deux#comments</comments>
		<pubDate>Thu, 17 Jul 2008 02:58:45 +0000</pubDate>
		<dc:creator>Rob Slazas</dc:creator>
		
		<category><![CDATA[MATLAB]]></category>

		<category><![CDATA[statistics]]></category>

		<category><![CDATA[ANSI Z1.9]]></category>

		<category><![CDATA[blinkdagger]]></category>

		<category><![CDATA[breath holding]]></category>

		<category><![CDATA[descriptive statistics]]></category>

		<category><![CDATA[Kurtosis]]></category>

		<category><![CDATA[MATLAB blog]]></category>

		<category><![CDATA[platykurtosis]]></category>

		<category><![CDATA[Rob Slazas]]></category>

		<category><![CDATA[Skewness]]></category>

		<guid isPermaLink="false">http://www.blinkdagger.com/?p=199</guid>
		<description><![CDATA[We left off last time with central tendency, spread, and trying to beat Quan in a breath-holding contest.  In this post we will continue the topic of descriptive statistics by covering shape.
            
Contents

Platy-kur-what?
Quantifying Shape
A Real-Life Use of Shape
Wrapping up

Platy-kur-what?
When it comes to describing [...]]]></description>
			<content:encoded><![CDATA[<p>We left off <a href="http://www.blinkdagger.com/matlab/intro-to-statistics-descriptive-statistics">last time</a> with <b>central tendency</b>, <b>spread</b>, and trying to beat Quan in a breath-holding contest.  In this post we will continue the topic of <i>descriptive statistics</i> by covering <b>shape</b>.
            </p>
<h2 id="toc-contents">Contents</h2>
<ul>
<li><a href="#1">Platy-kur-what?</a></li>
<li><a href="#3">Quantifying Shape</a></li>
<li><a href="#5">A Real-Life Use of Shape</a></li>
<li><a href="#7">Wrapping up</a></li>
</ul>
<h2 id="toc-platy-kur-what">Platy-kur-what?<a name="1"></a></h2>
<p>When it comes to describing the <b>shape</b> of a dataset, we are almost always visualizing it in the form of a histogram. Fortunately, the <tt>hist</tt> command is quite capable and flexible, which makes this work much easier. If we recall my breathholding data from last time, which we examined with a <tt>scatter</tt> / dot-plot and a <tt>boxplot</tt>, we can look at its shape this time in histogram form  (You can <a href="tutorials/MATLAB/stats/descriptive2/RobPracticeHolds.mat?PHPSESSID=2e167e6c07168745f29264e3fee581c0">download the .mat file here</a>).
         </p>
<pre class="codeinput">load <span class="string">RobPracticeHolds.mat</span>;
h1 = figure(<span class="string">'Position'</span>,[100 100 600 400],<span class="string">'Color'</span>,<span class="string">'w'</span>);
subplot(4,1,1:2); hist(breathholds);
  title(<span class="string">'Practice Holds'</span>); showx = get(gca,<span class="string">'Xlim'</span>);
subplot(4,1,3); boxplot(breathholds,<span class="string">'orientation'</span>,<span class="string">'horizontal'</span>,<span class="string">'widths'</span>,.5);
  set(gca,<span class="string">'Yticklabel'</span>,[],<span class="string">'Xlim'</span>,showx); xlabel(<span class="string">''</span>); ylabel(<span class="string">''</span>);
subplot(4,1,4); scatter(breathholds,ones(size(breathholds)));
  set(gca,<span class="string">'Yticklabel'</span>,[],<span class="string">'Xlim'</span>,showx); xlabel(<span class="string">'seconds'</span>);
</pre>
<p><img vspace="5" hspace="5" src="http://www.blinkdagger.com/tutorials/MATLAB/stats/descriptive2/dstat2_01.png" alt="Stat Pic 1" class="center"/></p>
<p><span id="more-199"></span></p>
<p>The <b><i><tt>hist</tt></i></b> function (top graph) does a few things: first it fits 10 &#8220;bins&#8221; equispaced within the range of the data (default is 10 bins, but using the <i>nbins</i> input arg changes that); then it counts the number of points that land inside of each of those bins; and finally it draws a vertical bar graph of that count, using bar widths to fit those bins.
         </p>
<p>The data takes on a &#8220;toothier&#8221; look using <tt>hist</tt>, where the main features are the 2 peak bins with 8 points each, and an empty bin to the right, sitting between the outlier and the rest of the data. In general, I would &#8220;eyeball&#8221; this shape to be slightly asymmetric, with the longer tail going out to the right (called <i>skewed to the right</i>). It also looks like a somewhat flat / wide shape since the data is not tightly grouped (called <i>platykurtosis</i>).
         </p>
<p>These visual observations of shape are nice, but they sound too much like art critique to be useful. The next questions you might have are: what do they mean, and is there are way to quantify them so we don&#8217;t have to rely on the subjectiveness of the &#8220;eyeball&#8221; method?
         </p>
<h2 id="toc-quantifying-shape">Quantifying Shape<a name="3"></a></h2>
<p>When looking at histograms, the 2 basic ways to quantify their shape goes to answering 2 questions about them:</p>
<ul>
<li>Is the data asymmetric, and if so - which way does it tilt?</li>
<li>How is the data spread out - wide and flat or skinny and tall?</li>
</ul>
<p><b><i><tt>Skewness</tt></i></b> answers the first question about symmetry. For a given dataset, it compares the tails on the left and right sides of the mean against each other. Perfectly symmetrical tails (such as the <i>Normal Distribution</i> has) return a <tt>skewness</tt> value of zero. Datasets with a heavier left tail return negative numbers (<i>skewed to the left</i>), while heavier right tails return positive numbers (<i>skewed to the right</i>). The greater the magnitude of <tt>skewness</tt>, the less balanced the tails.
         </p>
<pre class="codeinput">myskew = skewness(breathholds);
disp ([<span class="string">'My practice holds have a skewness of '</span>,num2str(myskew)]);
<span class="keyword">if</span> myskew+.1&lt;0
    disp(<span class="string">'So they are skewed to the left.'</span>);
<span class="keyword">elseif</span> myskew-.1&gt;0
    disp(<span class="string">'So they are skewed to the right.'</span>);
<span class="keyword">else</span>
    disp(<span class="string">'So they are approximately symmetrically distributed.'</span>);
<span class="keyword">end</span>
</pre>
<pre class="codeoutput">My practice holds have a skewness of 0.72107
So they are skewed to the right.
</pre>
<p><b><i><tt>Kurtosis</tt></i></b> answers the second question about how widely or narrowly the data is spread, compared to a <i>Normal Distribution</i>. This function sets the <tt>kurtosis</tt> of a perfect <i>Normal Distribution</i> equal to 3 (some other softwares subtract 3 so that perfect Normal equals zero). If the given distribution is flatter / wider than <i>Normal</i>, then <tt>kurtosis</tt> returns values greater than 3 (indicating that more outliers could be present). For a narrower / taller than <i>Normal</i> distribution, the <tt>kurtosis</tt> is less than 3 (indicating outliers are less likely).
         </p>
<pre class="codeinput">mykurt = kurtosis(breathholds);
disp ([<span class="string">'My practice holds have a kurtosis of '</span>,num2str(mykurt)]);
<span class="keyword">if</span> mykurt+.1&lt;3
    disp(<span class="string">'So they are narrower than Normal.'</span>);
<span class="keyword">elseif</span> mykurt-.1&gt;3
    disp(<span class="string">'So they are flatter than Normal.'</span>);
<span class="keyword">else</span>
    disp(<span class="string">'So they are spread about the same as Normal.'</span>);
<span class="keyword">end</span>
</pre>
<pre class="codeoutput">My practice holds have a kurtosis of 3.1865
So they are flatter than Normal.
</pre>
<h2 id="toc-a-real-life-use-of-shape">A Real-Life Use of Shape<a name="5"></a></h2>
<p>Like a lot of things in math, you might be thinking <i>&#8220;OK, that&#8217;s nice. But when would I use this?&#8221;</i> The uses of <b>shape</b> parameters appear most often when checking to see if certain <i>inferential statistics</i> are appropriate for your data. Particularly with statistical tests that depend on the shape being approximately Normal, or those that focus on what the tails are doing.
         </p>
<p>For example, an industry standard test to determine if a group of values meets a specification based on a small sample (i.e. only testing a few out of the group) is found in ANSI Z1.9. This test procedure makes assumptions about the <tt>skewness</tt> and <tt>kurtosis</tt> (symmetry and flatness) of the dataset being close to that of the <i>Normal Distribution</i>. If you have a one-sided specification, let&#8217;s say it is higher-is-better, then data that is <i>skewed to the right</i> would be more likely to fail this test unnecessarily. In fact, you would be penalized for better performance (higher values)!
         </p>
<pre class="codeinput">h2 = figure(<span class="string">'Position'</span>,[100 100 600 400],<span class="string">'Color'</span>,<span class="string">'w'</span>);
histfit(breathholds); title(<span class="string">'Practice Holds Compared to ANSI Z1.9'</span>);
legend(<span class="string">'My data'</span>,<span class="string">'ANSI Z1.9 thinks'</span>);
annotation(<span class="string">'textarrow'</span>,[.25 .32],[.6 .13],<span class="keyword">...</span>
    <span class="string">'string'</span>,[{<span class="string">'Overestimate of'</span>};{<span class="string">'the left tail'</span>}]);
annotation(<span class="string">'line'</span>,[.35 .35],[.11 .92],<span class="string">'color'</span>,<span class="string">'r'</span>,<span class="string">'linewidth'</span>,2);
</pre>
<p><img vspace="5" hspace="5" src="http://www.blinkdagger.com/tutorials/MATLAB/stats/descriptive2/dstat2_02.png" alt="Stat pic 2" class="center" /> </p>
<p>So, let&#8217;s assume that I cannot accept a breath hold time of less than 40 seconds. If we were to run the ANSI Z1.9 test on my practice breathholding data, the higher times cause the test to assume the variation is symmetric (like the Normal distribution).  It therefore concludes that the left tail (low values) extends below our lower limit of 40 by an unacceptable amount (we fail the test).
         </p>
<p>So, when testing to see if I can hold my breath for an acceptable amount of time, I should choose something other than ANSI Z1.9 since my data is skewed. Continuing to use this type of test would be overly conservative and reject some good results.
         </p>
<h2 id="toc-wrapping-up">Wrapping up<a name="7"></a></h2>
<p>That&#8217;s it for our introduction to descriptive statistics. In the next post we&#8217;ll tidy up with a few of my favorite visualizations for descriptive stats.  Then, from there on, we&#8217;re going to be talking about <i>inferential statistics</i>, how they&#8217;re used, and what visualizations go along with them. As usual, questions and comments are welcome below.
         </p>
<p>a</p>
<p><a href="http://www.blinkdagger.com/matlab/descriptive-statistics-parte-deux">Descriptive Statistics - Parte Deux</a></p>
<img src="http://feeds.feedburner.com/~r/blinkdaggerMatlab/~4/337662767" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.blinkdagger.com/matlab/descriptive-statistics-parte-deux/feed</wfw:commentRss>
		<feedburner:origLink>http://www.blinkdagger.com/matlab/descriptive-statistics-parte-deux</feedburner:origLink></item>
		<item>
		<title>MATLAB - Blinkdagger Needs Your Help!</title>
		<link>http://feeds.feedburner.com/~r/blinkdaggerMatlab/~3/334568296/matlab-blinkdagger-needs-your-help</link>
		<comments>http://www.blinkdagger.com/matlab/matlab-blinkdagger-needs-your-help#comments</comments>
		<pubDate>Sun, 13 Jul 2008 21:49:51 +0000</pubDate>
		<dc:creator>Quan Quach</dc:creator>
		
		<category><![CDATA[MATLAB]]></category>

		<category><![CDATA[blog]]></category>

		<category><![CDATA[help blinkdagger]]></category>

		<category><![CDATA[script]]></category>

		<category><![CDATA[write function]]></category>

		<guid isPermaLink="false">http://www.blinkdagger.com/index.php/?p=182</guid>
		<description><![CDATA[ One of the things that has been annoying me lately is that some of our older posts refer to &#8220;MATLAB&#8221; as &#8220;Matlab&#8221;, an egregious error on our part.   What&#8217;s the easiest way to remedy this problem?  Can MATLAB help us fix this problem?
Contents


The Problem Description
The Desired Solution
Posting your Code
What&#8217;s in it [...]]]></description>
			<content:encoded><![CDATA[<p><img src="http://www.blinkdagger.com/tutorials/matlab/matlab-icon.jpg" align = "left" alt="Matlab Logo" hspace = "10"  /> One of the things that has been annoying me lately is that some of our older posts refer to &#8220;MATLAB&#8221; as &#8220;Matlab&#8221;, an egregious error on our part.   What&#8217;s the easiest way to remedy this problem?  Can MATLAB help us fix this problem?</p>
<h2 id="toc-contents">Contents</h2>
<div>
<ul>
<li><a href="#1">The Problem Description</a></li>
<li><a href="#2">The Desired Solution</a></li>
<li><a href="#3">Posting your Code</a></li>
<li><a href="#4">What&#8217;s in it for Me?</a></li>
</ul></div>
<h2 id="toc-the-problem-description">The Problem Description<a name="1"></a></h2>
<p>The MATLAB capitalization mistake wasn&#8217;t brought to my attention until after we had published about 40 posts, so to go back and correct it manually would take a Herculean effort.  Thus, we were thinking that a MATLAB script would come in handy.  I was about to write a MATLAB function to help me fix this error, but then I thought it would be a good chance for one of our readers to show off their MATLAB prowess by helping us with this little problem.  </p>
<h2 id="toc-the-desired-solution">The Desired Solution<a name="2"></a></h2>
<p>You can download the sample input file <a href="/wp-content/uploads/2008/07/MATLAB GUI Tutorial - Slider.txt?PHPSESSID=2e167e6c07168745f29264e3fee581c0">here</a>. (Right Click the link and use &#8220;Save As&#8221;)  The sample file is the HTML code for the <a href="http://www.blinkdagger.com/matlab/matlab-gui-tutorial-slider">Slider Tutorial</a>.  </p>
<ol>
<li>The MATLAB function should be able to take in as input the name of a text file.  To further elaborate, the input to the function should be a string which represents the input file&#8217;s name.  In this case, the input will be:
<pre class="codeinput"><span class="string">'MATLAB GUI Tutorial - Slider.txt'</span></pre>
<p>Note: There are plenty of ways to code this part of the function, and we don&#8217;t really care how it is done as long as it gets the job done.  You might find the <code>uigetfile</code> command to be useful here as well!</li>
<li>The function should search within the text file for any incorrect instances of <strong>MATLAB</strong> such as <code>Matlab</code>, <code>matlab</code>, or <code>MatLab</code> and replace it with <strong>MATLAB</strong>.  </li>
<li>The output of the function should be a text file with the same name of the input file, but with an &#8220;_fixed&#8221; appended to the end of the file name. For example, if the input file is named &#8220;test.txt&#8221;, then the output file should be named &#8220;text_fixed.txt&#8221;.  For this particular example, the output name for the text file should be:
<pre class="codeinput"><span class="string">'MATLAB GUI Tutorial - Slider_fixed.txt'</span></pre>
</li>
<li>The contents of the output file should be identical to the contents of the input file, save any corrections related to the capitalization of MATLAB. A good way to see if the output file is correct is to change the extension of the text file from <strong>.txt</strong> to <strong>.html</strong>, and then open it.  Hopefully everything should be the same from the input file!</li>
<li>Extra Work:  Since we have over 40 posts to correct, it would be nice if this process could be automated to fix all text files within a given directory.</li>
</ol>
<h2 id="toc-posting-your-code">Posting your Code<a name="3"></a></h2>
<p>You can post your code in the comments section in the following method:</p>
<p><img src="/wp-content/uploads/2008/07/pasteCode.png" alt="pasteCode.png" title="pasteCode.png" width="633" height="303" border="1" class="center" /></p>
<h2 id="toc-whats-in-it-for-me">What&#8217;s in it for Me?<a name="3"></a></h2>
<p>Unfortunately, we don&#8217;t have much to offer in prizes and riches.  But, if we choose to use your code, we will feature you in a future Blinkdagger post, cementing your MATLAB legacy on the world wide web.  Good luck, and thanks to everyone who decides to contribute!</p>
<p>a</p>
<p><a href="http://www.blinkdagger.com/matlab/matlab-blinkdagger-needs-your-help">MATLAB - Blinkdagger Needs Your Help!</a></p>
<img src="http://feeds.feedburner.com/~r/blinkdaggerMatlab/~4/334568296" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.blinkdagger.com/matlab/matlab-blinkdagger-needs-your-help/feed</wfw:commentRss>
		<feedburner:origLink>http://www.blinkdagger.com/matlab/matlab-blinkdagger-needs-your-help</feedburner:origLink></item>
		<item>
		<title>MATLAB GUI - Creating a Reset Button Part II</title>
		<link>http://feeds.feedburner.com/~r/blinkdaggerMatlab/~3/333227464/matlab-gui-creating-a-reset-button-part-ii</link>
		<comments>http://www.blinkdagger.com/matlab/matlab-gui-creating-a-reset-button-part-ii#comments</comments>
		<pubDate>Sat, 12 Jul 2008 01:37:10 +0000</pubDate>
		<dc:creator>Quan Quach</dc:creator>
		
		<category><![CDATA[Advanced]]></category>

		<category><![CDATA[GUI]]></category>

		<category><![CDATA[MATLAB]]></category>

		<category><![CDATA[blinkdagger]]></category>

		<category><![CDATA[Matlab GUI]]></category>

		<category><![CDATA[Matlab GUI tutorial]]></category>

		<category><![CDATA[reset]]></category>

		<category><![CDATA[reset button]]></category>

		<category><![CDATA[reset GUI]]></category>

		<category><![CDATA[tutorial]]></category>

		<guid isPermaLink="false">http://www.blinkdagger.com/?p=177</guid>
		<description><![CDATA[Introduction
 In the previous Reset Button tutorial, we discussed how to create a reset button.  In this tutorial, we will discuss a different approach to creating a reset button.  There are pros and cons to both methods, and we&#8217;ll go over those in a bit. 
In the previous tutorial, we coded a reset [...]]]></description>
			<content:encoded><![CDATA[<h2 id="toc-introduction">Introduction</h2>
<p><img src="http://www.blinkdagger.com/tutorials/matlab/matlab-icon.jpg" align = "left" alt="Matlab Logo" hspace = "10"  /> In the <a href="http://www.blinkdagger.com/matlab/MATLAB-gui-creating-a-reset-button">previous Reset Button tutorial</a>, we discussed how to create a reset button.  In this tutorial, we will discuss a different approach to creating a reset button.  There are pros and cons to both methods, and we&#8217;ll go over those in a bit. </p>
<p>In the previous tutorial, we coded a reset button that opened a new instance of the GUI and closed the old instance.  In this tutorial, we are going to create a reset button by setting all the pertinent values within the GUI to their default values.  In addition, we will clear all axes of their data and labels.  For this tutorial, we will be working with the GUI shown below.</p>
<p style="text-align: center"><img src="http://www.blinkdagger.com/tutorials/matlab/GUI/advanced/reset-gui/super3.png" alt="Finished GUI" /></p>
<p><span id="more-177"></span></p>
<h2 id="toc-the-example-files-and-code">The Example Files and Code</h2>
<ol>
<li>
<p>First, download the GUI skeleton <a href="http://www.blinkdagger.com/tutorials/matlab/GUI/advanced/reset-gui/reset-GUI2.zip">here</a>.   Unzip the files and place them wherever you please. </p>
</li>
<li>
<p>Now, type <code>guide</code> at the command prompt.</p>
<p style="text-align: center"><img src="http://www.blinkdagger.com/tutorials/matlab/GUI/basic/handles-intro/image001.png" alt="Command prompt" /></p>
</li>
<li>
<p>Choose to open the sample GUI by clicking on &#8220;Open Existing GUI&#8221;.  Click on &#8220;Browse&#8221; to locate where you saved the GUI files.</p>
<p style="text-align: center"><img src="http://www.blinkdagger.com/tutorials/matlab/GUI/basic/handles-intro/image003.png" alt="GUIDE Screen" /></p>
</li>
<li>
<p>Here is what the GUI should look like when you open it:</p>
<p style="text-align: center"><img src="http://www.blinkdagger.com/tutorials/matlab/GUI/advanced/reset-gui/super1.png" alt="GUI Skeleton" /></p>
</li>
<li>
<p>Click on the <img src="http://www.blinkdagger.com/tutorials/matlab/GUI/basic/handles-intro/image007.png" alt="mfile icon" /> icon on the GUI figure to bring up the accompanying .m file.</p>
</li>
<li>
<p>Find the <em>reset_Callback</em> and add the following code </p>

<div class="wp_syntax"><div class="code"><pre class="matlab">reset_gui; <span style="color: #228B22;">%calls the reset_gui m file</span></pre></div></div>

</li>
<li>
<p>Create an m-file named <em>reset_gui</em>.  Make sure it&#8217;s located in the same directory as the other two files.  This m-file will store all the initialization values for the reset button.  When you press the reset button, it will set all the parameters to the values specified in this m-file.  Paste the following code into the m-file:  </p>

<div class="wp_syntax"><div class="code"><pre class="matlab"><span style="color: #228B22;">%the following code initializes the relevant parameters to their default values</span>
<span style="color: #228B22;">%this is essentially what a reset button does!</span>
<span style="color: #0000FF;">set</span><span style="color: #080;">&#40;</span>handles.<span style="">input1_editText</span>,<span style="color:#A020F0;">'String'</span>,<span style="color:#A020F0;">'0'</span><span style="color: #080;">&#41;</span>;  <span style="color: #228B22;">%sets input1 to 0</span>
<span style="color: #0000FF;">set</span><span style="color: #080;">&#40;</span>handles.<span style="">input2_editText</span>,<span style="color:#A020F0;">'String'</span>,<span style="color:#A020F0;">'0'</span><span style="color: #080;">&#41;</span>;  <span style="color: #228B22;">%sets input2 to 0</span>
<span style="color: #0000FF;">set</span><span style="color: #080;">&#40;</span>handles.<span style="">answer_staticText</span>,<span style="color:#A020F0;">'String'</span>,<span style="color:#A020F0;">'0'</span><span style="color: #080;">&#41;</span>; <span style="color: #228B22;">%sets answer to 0</span>
<span style="color: #0000FF;">cla</span><span style="color: #080;">&#40;</span>handles.<span style="">axes1</span>,<span style="color:#A020F0;">'reset'</span><span style="color: #080;">&#41;</span>; <span style="color: #228B22;">%clears the axes</span></pre></div></div>

</li>
<li>
<p>Note:  Instead of creating a separate m-file, we could have just added the previous code directly into the <em>reset_Callback</em> function.  Since this GUI is simple, it would have been easier to do it that way.  But when you have a larger GUI with many more parameters, it is easier to designate an m-file to initialize your parameters.  </p>
</li>
<li>
<p> Now run the GUI and test it out!  Input some numbers and add them.  Plot the data.  Once you are done, try the reset button.</p>
</li>
</ol>
<h2 id="toc-advantages-and-disadvantages">Advantages and Disadvantages</h2>
<p>The main advantage of coding the reset button this way is that there is no &#8220;flicker&#8221; when you activate the reset button.  On the flip side, one of the main disadvantages is that you have to hardcode the initialization code for each parameter.  If you decide to make modifications to your GUI, you would have to manually change the initialization code to keep up with all the relevant parameters.  With the other <a href="http://www.blinkdagger.com/matlab/matlab-gui-creating-a-reset-button">reset button method</a>, you never have to worry about this.  </p>
<h2 id="toc-conclusion">Conclusion</h2>
<p>In this tutorial, you learned a different way to implement a reset button.  I prefer using this method to code my reset button because I really don&#8217;t like the flickering from the previous method.  It may take a little extra diligence, but the end product is superior in my opinion.  </p>
<h2 id="toc-download-the-source-files">Download the Source Files</h2>
<p>Click <a href="http://www.blinkdagger.com/tutorials/matlab/GUI/advanced/reset-gui/reset-GUI2.zip">here</a> to download the source files.</p>
<p>This is the end of the tutorial.</p>
<p>a</p>
<p><a href="http://www.blinkdagger.com/matlab/matlab-gui-creating-a-reset-button-part-ii">MATLAB GUI - Creating a Reset Button Part II</a></p>
<img src="http://feeds.feedburner.com/~r/blinkdaggerMatlab/~4/333227464" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.blinkdagger.com/matlab/matlab-gui-creating-a-reset-button-part-ii/feed</wfw:commentRss>
		<feedburner:origLink>http://www.blinkdagger.com/matlab/matlab-gui-creating-a-reset-button-part-ii</feedburner:origLink></item>
		<item>
		<title>MATLAB GUI - Creating a Reset Button</title>
		<link>http://feeds.feedburner.com/~r/blinkdaggerMatlab/~3/330883888/matlab-gui-creating-a-reset-button</link>
		<comments>http://www.blinkdagger.com/matlab/matlab-gui-creating-a-reset-button#comments</comments>
		<pubDate>Wed, 09 Jul 2008 15:30:40 +0000</pubDate>
		<dc:creator>Quan Quach</dc:creator>
		
		<category><![CDATA[Advanced]]></category>

		<category><![CDATA[GUI]]></category>

		<category><![CDATA[MATLAB]]></category>

		<category><![CDATA[blinkdagger]]></category>

		<category><![CDATA[MATLAB blog]]></category>

		<category><![CDATA[Matlab GUI]]></category>

		<category><![CDATA[reset]]></category>

		<category><![CDATA[reset button]]></category>

		<guid isPermaLink="false">http://www.blinkdagger.com/?p=167</guid>
		<description><![CDATA[Introduction
 In this tutorial, you will learn how to create a reset button for a GUI.  A reset button can be very useful as it quickly returns everything on the GUI to a default value.  There are two main ways that I can think of to implement a reset button, and in this [...]]]></description>
			<content:encoded><![CDATA[<h2 id="toc-introduction">Introduction</h2>
<p><img src="http://www.blinkdagger.com/tutorials/matlab/matlab-icon.jpg" align = "left" alt="Matlab Logo" hspace = "10"  /> In this tutorial, you will learn how to create a reset button for a GUI.  A reset button can be very useful as it quickly returns everything on the GUI to a default value.  There are two main ways that I can think of to implement a reset button, and in this tutorial I will introduce one of the methods.  I will cover the other method in a different tutorial.  Here is a quick look at the finished GUI.  </p>
<p style="text-align: center"><img src="http://www.blinkdagger.com/tutorials/matlab/GUI/advanced/reset-gui/1.png" alt="Finished GUI" /></p>
<p><span id="more-167"></span></p>
<h2 id="toc-the-example-files-and-code">The Example Files and Code</h2>
<ol>
<li>
<p>First, download the GUI skeleton <a href="http://www.blinkdagger.com/tutorials/matlab/GUI/advanced/reset-gui/reset-GUI.zip">here</a>.   Unzip the files and place them wherever you please. </p>
</li>
<li>
<p>Now, type <code>guide</code> at the command prompt.</p>
<p style="text-align: center"><img src="http://www.blinkdagger.com/tutorials/matlab/GUI/basic/handles-intro/image001.png" alt="Command prompt" /></p>
</li>
<li>
<p>Choose to open the sample GUI by clicking on &#8220;Open Existing GUI&#8221;.  Click on &#8220;Browse&#8221; to locate where you saved the GUI files.</p>
<p style="text-align: center"><img src="http://www.blinkdagger.com/tutorials/matlab/GUI/basic/handles-intro/image003.png" alt="GUIDE Screen" /></p>
</li>
<li>
<p>Here is what the GUI should look like when you open it:</p>
<p style="text-align: center"><img src="http://www.blinkdagger.com/tutorials/matlab/GUI/advanced/reset-gui/2.png" alt="GUI Skeleton" /></p>
</li>
<li>
<p> Next, we must allow the GUI to run multiple instances.  Go to the <em>Tools </em>tab, and then to <em>GUI Options</em>.  Disable the following option as shown: </p>
<p style="text-align: center"><img src="http://www.blinkdagger.com/tutorials/matlab/GUI/advanced/reset-gui/3.png" alt="GUI Skeleton" /></p>
</li>
<li>
<p>Click on the <img src="http://www.blinkdagger.com/tutorials/matlab/GUI/basic/handles-intro/image007.png" alt="mfile icon" /> icon on the GUI figure to bring up the accompanying .m file.</p>
</li>
<li>
<p>Find the <em>reset_Callback</em> and add the following code </p>

<div class="wp_syntax"><div class="code"><pre class="matlab">closeGUI = handles.<span style="">figure1</span>; <span style="color: #228B22;">%handles.figure1 is the GUI figure</span>
&nbsp;
guiPosition = <span style="color: #0000FF;">get</span><span style="color: #080;">&#40;</span>handles.<span style="">figure1</span>,<span style="color:#A020F0;">'Position'</span><span style="color: #080;">&#41;</span>; <span style="color: #228B22;">%get the position of the GUI</span>
guiName = <span style="color: #0000FF;">get</span><span style="color: #080;">&#40;</span>handles.<span style="">figure1</span>,<span style="color:#A020F0;">'Name'</span><span style="color: #080;">&#41;</span>; <span style="color: #228B22;">%get the name of the GUI</span>
<span style="color: #0000FF;">eval</span><span style="color: #080;">&#40;</span>guiName<span style="color: #080;">&#41;</span> <span style="color: #228B22;">%call the GUI again</span>
&nbsp;
<span style="color: #0000FF;">close</span><span style="color: #080;">&#40;</span>closeGUI<span style="color: #080;">&#41;</span>; <span style="color: #228B22;">%close the old GUI</span>
<span style="color: #0000FF;">set</span><span style="color: #080;">&#40;</span><span style="color: #0000FF;">gcf</span>,<span style="color:#A020F0;">'Position'</span>,guiPosition<span style="color: #080;">&#41;</span>; <span style="color: #228B22;">%set the position for the new GUI</span></pre></div></div>

</li>
<li>
<p> Now run the GUI and test it out!  You should see a brief flicker when you reset the GUI, as a new GUI is being opened while the old one is closed.</p>
</li>
</ol>
<h2 id="toc-conclusion">Conclusion</h2>
<p>In this tutorial, you learned how to implement a reset button.  Although the flickering can be a tad annoying when the GUI is reset, it gets the job done.  It should be noted that multiple copies of the same GUI is now possible since we changed the option to allow multiple copies of the GUI to run.  Thus, if you call the GUI twice, you will get two copies of the GUI to run simultaneously!</p>
<p>The next GUI tutorial will show you how to implement a reset button by creating an m-file to initialize all the values within the GUI.  </p>
<p>There are probably other ways that a reset button can be implemented.  Please share your ideas!</p>
<h2 id="toc-download-the-source-files">Download the Source Files</h2>
<p>Click <a href="http://www.blinkdagger.com/tutorials/matlab/GUI/advanced/reset-gui/reset-GUI.zip">here</a> to download the source files.</p>
<p>This is the end of the tutorial.</p>
<p>a</p>
<p><a href="http://www.blinkdagger.com/matlab/matlab-gui-creating-a-reset-button">MATLAB GUI - Creating a Reset Button</a></p>
<img src="http://feeds.feedburner.com/~r/blinkdaggerMatlab/~4/330883888" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.blinkdagger.com/matlab/matlab-gui-creating-a-reset-button/feed</wfw:commentRss>
		<feedburner:origLink>http://www.blinkdagger.com/matlab/matlab-gui-creating-a-reset-button</feedburner:origLink></item>
		<item>
		<title>Joining The MathWorks Team</title>
		<link>http://feeds.feedburner.com/~r/blinkdaggerMatlab/~3/327248406/joining-the-mathworks-team</link>
		<comments>http://www.blinkdagger.com/matlab/joining-the-mathworks-team#comments</comments>
		<pubDate>Sat, 05 Jul 2008 06:34:28 +0000</pubDate>
		<dc:creator>Daniel Sutoyo</dc:creator>
		
		<category><![CDATA[MATLAB]]></category>

		<category><![CDATA[blog]]></category>

		<category><![CDATA[job]]></category>

		<category><![CDATA[mathworks]]></category>

		<guid isPermaLink="false">http://www.blinkdagger.com/?p=168</guid>
		<description><![CDATA[On 12/14/2007, I received an email from Doug Hull, who runs the Pick of the Week blog at the official MathWork’s website.  In his email, he was interested in featuring blinkdagger as the Pick of the Week!  Of course, we were pretty excited that a MATLAB celebrity like Doug would recognize a blog [...]]]></description>
			<content:encoded><![CDATA[<p><img src="http://www.blinkdagger.com/wp-content/uploads/2008/MathWorks/mathworks_draft.jpg" alt="MathWorks" title="join_mathworks"></a></p>
<p>On 12/14/2007, I received an email from Doug Hull, who runs the <a href="http://blogs.mathworks.com/pick/">Pick of the Week blog</a> at the official <a href="http://www.mathworks.com">MathWork’s website</a>.  In his email, he was interested in featuring blinkdagger as the Pick of the Week!  Of course, we were pretty excited that a MATLAB celebrity like Doug would recognize a blog like ours.  Being featured on his blog really helped us gain exposure and authority in the MATLAB niche.  In addition, he even gave us some cool MATLAB t-shirts.</p>
<p>One thing led to another. A few weeks later, Scott Hirsch, a Program Manager at The MathWorks, asked if Quan and I would be interested in applying for a position at The MathWorks. Both of us sent in our resumes and went through the interview process.  </p>
<p>Before I knew it, I had <strong>accepted a position at The MathWorks!</strong> My start date end of 2008.  This is very significant news, and I wanted to share the news with all of our readers.  Also, I forgot to mention that this is the <strong>100th post for Blinkdagger</strong>!  Below is a quick history of our website and the plans we have in store for the future.<br />
<em>Note: Quan also received an offer from The Mathworks,  but declined the offer. </em><br />
<span id="more-168"></span> </p>
<h2 id="toc-the-motivation">The Motivation</h2>
<p>I am sure <strong>we all have googled our names</strong> in the past out of curiosity. Even if your name is crammed on the search engine space with 5 other people of the same name, you will eventually find a unique link that describes you. Whether this description is interesting and meaningful is difficult to control for the vast majority.  </p>
<p>With Facebook, Linked In, Blogger and other internet social medium, you can customize the imprint you are leaving on the Internet.  But revealing what my favorite movies are on my profile was not the Internet ownership I sought. <strong>I wanted to be part of something big, something with an impact</strong>. I wanted people to remember me for the work I did.   I have failed several times in the past to get anything going.   I knew I could not do this alone, so I asked my best friend Quan Quach to form a partnership.</p>
<h2 id="toc-finding-our-identity">Finding our Identity </h2>
<p>Finding our niche was no easy task. It felt like we started several years behind everyone else and that all the good ideas were already taken. Neither Quan nor I felt like we possessed special knowledge superior to anyone else. As dismal as this looked, we understood how we could be successful in two simple steps <strong>1) Make it quality 2) Make it easy to understand</strong>. The next question we faced was a difficult one, “What do we write about?”</p>
<p>In the very beginning, Quan and I were figuring out how to get a hosting program called Listchecker to work. People complained it was difficult to set up and that instructions were not detailed enough. We decided to take all the information available on Listchecker and to convert it into a tutorial that was easy to understand and easy to follow.   <strong>The Listchecker tutorial became an instant hit (150+k views and 750+ comments)</strong>. The same information is available elsewhere, but our 2 criteria set us apart. With this initial success we decided to transfer the same framework to our other strength, MATLAB.</p>
<h2 id="toc-if-you-build-it-they-will-come">If You Build It, They Will Come</h2>
<p>Given enough time and patience, most of us can probably figure out what we need through the Help and Documentation that MATLAB provides. If that fails you can probably find your answer on google or ask in the compsys forum. But like many of you have experienced, <strong>many tutorials have skipped steps, contain unclear directions, or are filled with unnecessary technical jargon</strong>. We felt like this something worth exploring. We launched a series of tutorials focused on MATLAB GUIs.  The series have been quite successful and we have received many thank you emails in the past few months. We were really encouraged with the feeback.  Soon after, we received an e-mail from Doug on that fateful day, and the rest is history.  </p>
<h2 id="toc-what-now">What now?</h2>
<p>My decision to join The MathWorks will hopefully become a catalyst for this site to grow. We envision this site to offer the best MATLAB tutorials on the net. Although we are still in a beta phase, there is certainly a lot of new things brewing behind. We can’t wait to share them with you. To satisfy some of your curiosity we will be incorporating</p>
<ul>
<li>New MATLAB series</li>
<li>Much needed Forum for better Q&#038;A (Apologize to those who I missed in responding to their MATLAB questions)</li>
<li>Moderated Links Database</li>
<li>Brand new layout</li>
</ul>
<p>We hope you share the same excitement as us. We are also <strong>extending invitations to people who want to contribute</strong> to our site (especially if you are interested in working for MathWorks!). We’ve had some guest posters recently (Rob Slazas and Will Dwinnel) who have written some excellent posts.  We look forward to hearing from everyone!</p>
<p>a</p>
<p><a href="http://www.blinkdagger.com/matlab/joining-the-mathworks-team">Joining The MathWorks Team</a></p>
<img src="http://feeds.feedburner.com/~r/blinkdaggerMatlab/~4/327248406" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.blinkdagger.com/matlab/joining-the-mathworks-team/feed</wfw:commentRss>
		<feedburner:origLink>http://www.blinkdagger.com/matlab/joining-the-mathworks-team</feedburner:origLink></item>
		<item>
		<title>Monday Math Madness #8:  Blinkdagger Bullies</title>
		<link>http://feeds.feedburner.com/~r/blinkdaggerMatlab/~3/308292315/monday-math-madness-8-blinkdagger-bullies</link>
		<comments>http://www.blinkdagger.com/matlab/monday-math-madness-8-blinkdagger-bullies#comments</comments>
		<pubDate>Mon, 09 Jun 2008 20:45:51 +0000</pubDate>
		<dc:creator>Quan Quach</dc:creator>
		
		<category><![CDATA[MATLAB]]></category>

		<category><![CDATA[blog]]></category>

		<category><![CDATA[monday math madness]]></category>

		<category><![CDATA[blinkdagger]]></category>

		<category><![CDATA[mensa]]></category>

		<guid isPermaLink="false">http://www.blinkdagger.com/?p=159</guid>
		<description><![CDATA[Special Thanks to this week&#8217;s Sponsor, Mensa!

Before we introduce the problem for this week, we would like to take some time to thank our great sponsor, Mensa.  
Mensa is the largest, oldest, and most famous high-IQ society in the world.  The non-profit organization restricts its membership to people with high testable IQs. Members [...]]]></description>
			<content:encoded><![CDATA[<p><img src="http://www.blinkdagger.com/wp-content/uploads/2008/MMM/mmm.jpg" alt="Monday Math Madness!" /></p>
<h2 id="toc-special-thanks-to-this-weeks-sponsor-mensa">Special Thanks to this week&#8217;s Sponsor, Mensa!</h2>
<p><img src="http://www.blinkdagger.com/wp-content/uploads/2008/MMM08/mensalogo.gif" alt="Mensa" /></p>
<p>Before we introduce the problem for this week, we would like to take some time to thank our great sponsor, <a href="http://www.us.mensa.org">Mensa</a>.  </p>
<p><a href="http://www.us.mensa.org">Mensa</a> is the largest, oldest, and most famous high-IQ society in the world.  The non-profit organization restricts its membership to people with high testable IQs. Members must score at the 98th percentile or higher of a standardized, supervised intelligence test.</p>
<p>The people at <a href="http://www.us.mensa.org">Mensa</a> have provided Blinkdagger with a bunch of books that range from crossword puzzles, sudoku puzzles, and even a casino gambling guide!  We will be handing out these books as the prizes for this contest.  For the international participants, we are still offering the 10 dollar gift certificate to Amazon.  See the <em>Rules</em> sections for more details!  Without further ado . . . let the games begin!</p>
<p><img src="http://www.blinkdagger.com/wp-content/uploads/2008/MMM08/twisted.jpg" vspace="10" hspace="10" alt="twisted crossswords" /><img src="http://www.blinkdagger.com/wp-content/uploads/2008/MMM08/casino.png" hspace="10" vspace="10" alt="casino" /><img src="http://www.blinkdagger.com/wp-content/uploads/2008/MMM08/crossword.png" hspace="10" vspace="10" alt="crosswords" /><br />
<img src="http://www.blinkdagger.com/wp-content/uploads/2008/MMM08/logic.png" hspace="10" alt="logic puzzles" /><img src="http://www.blinkdagger.com/wp-content/uploads/2008/MMM08/sudoku.png" hspace="10" alt="sudoku" /></p>
<p><span id="more-159"></span></p>
<h2 id="toc-the-problem-statement">The Problem Statement </h2>
<p>One Monday morning, Nelson and his two identical brothers are scouring the streets of Springfield, looking to beat up some helpless kids for their lunch money.  Their favorite target is a particular student named Martin, as he always has at least 20 dollars on him.  On one memorable occasion, Martin also had a couple of 10 dollar gift certificates that he won from some lame math contest.</p>
<p>There are three paths that one can take to get to Springfield Elementary School.  If Nelson and his brothers had any intelligence, they would each occupy a different path so that their chances of beating up Martin would be 100%.  But since Nelson and his identical brothers are not too bright, they randomly (and independently) choose a path to occupy.  Thus, it is possible that all three brothers could end up on one path, leaving the other two vacant. </p>
<p><strong>On average, what is the % chance of Martin making it to school safely?</strong></p>
<h2 id="toc-the-rules">The Rules</h2>
<ol>
<li>
<p>Email your answers to mondaymathmadness at gmail dot com.</p>
</li>
<li>
<p>The winner will get to choose from the collection of literature provided by Mensa. The number of winners will depend on the number of total submissions received</p>
</li>
<li>
<p>Depending on how many submissions we receive, we will be giving out additional prizes, giving you yet more chances to win.  We&#8217;d also like to give a prize out to the &#8220;best&#8221; or &#8220;most creative&#8221; answer.  These prizes will consist of a 10 dollar gift certificate to Amazon.com or this <a href="http://www.rubiksrevolution.com/">spiffy Rubik&#8217;s Cube</a> (the cube is only available to US participants and is <strong>not</strong> the traditional rubik&#8217;s cube that we all grew up with). </p>
<p style="text-align: center">
<img src="http://ecx.images-amazon.com/images/I/51zk60M0qhL._SL500_AA280_.jpg" alt="Rubik's Cube" />
</p>
</li>
<li>
<p>Inelgible for any one person to win more than once per year.  But you should still submit your answer! </p>
</li>
<li>
<p>Answer must be explained.  You must show your work!  We will accept answers in the form of a MATLAB script as well.   We will be the final judge on whether an answer was properly explained or not.</p>
</li>
<li>
<p><strong>The deadline to submit answers is June 17th 2008, Tuesday 12:00 AM Pacific Standard Time</strong></p>
</li>
<li>
<p>The winners will be chosen randomly from all the submittals using a <a href="http://www.random.org/">random number generator</a>.</p>
</li>
<li>
<p>The winner will be announced at 9:00 AM PST June 20th, 2008.</p>
</li>
<li>
<p>Comments for this post should only be used to clarify the problem.  Please do not discuss ANY potential solutions.</p>
</li>
<li>
<p>Please spread the word about our contest by stumbling this webpage!</p>
</li>
</ol>
<p>a</p>
<p><a href="http://www.blinkdagger.com/matlab/monday-math-madness-8-blinkdagger-bullies">Monday Math Madness #8:  Blinkdagger Bullies</a></p>
<img src="http://feeds.feedburner.com/~r/blinkdaggerMatlab/~4/308292315" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.blinkdagger.com/matlab/monday-math-madness-8-blinkdagger-bullies/feed</wfw:commentRss>
		<feedburner:origLink>http://www.blinkdagger.com/matlab/monday-math-madness-8-blinkdagger-bullies</feedburner:origLink></item>
		<item>
		<title>Intro to Statistics: Descriptive Statistics</title>
		<link>http://feeds.feedburner.com/~r/blinkdaggerMatlab/~3/303568202/intro-to-statistics-descriptive-statistics</link>
		<comments>http://www.blinkdagger.com/matlab/intro-to-statistics-descriptive-statistics#comments</comments>
		<pubDate>Tue, 03 Jun 2008 09:00:53 +0000</pubDate>
		<dc:creator>Rob Slazas</dc:creator>
		
		<category><![CDATA[MATLAB]]></category>

		<category><![CDATA[statistics]]></category>

		<guid isPermaLink="false">http://www.blinkdagger.com/?p=158</guid>
		<description><![CDATA[Rob Slazas, a R&#38;D engineer and 6-sigma blackbelt, joins us again to talk about statistics in MATLAB. 

Our first dive into the Statistics Toolbox will cover descriptive statistic. These are the functions that help us understand what data we have on hand. As we said in the introductory post, descriptive statistics stop there, and do [...]]]></description>
			<content:encoded><![CDATA[<p><em>Rob Slazas, a R&amp;D engineer and 6-sigma blackbelt, joins us again to talk about <strong>statistics in MATLAB</strong>. </em></p>
<p><img src="http://www.blinkdagger.com/tutorials/matlab/matlab-icon.jpg" align = "left" alt="Matlab Logo" hspace = "10"  /></p>
<p>Our first dive into the Statistics Toolbox will cover descriptive statistic. These are the functions that help us understand what data we have on hand. As we said in the <a href="http://www.blinkdagger.com/matlab/intro-to-statistics-matlab-style">introductory post</a>, descriptive statistics stop there, and do not make assumptions or reach conclusions about where your data came from, or how it compares to other datasets.</p>
<h2 id="toc-contents">Contents</h2>
<div>
<ul>
<li><a href="#1">Holding Our Breath</a></li>
<li><a href="#3">Central Tendency</a></li>
<li><a href="#5">Spread</a></li>
<li><a href="#10">The 5-in-1 tool</a></li>
<li><a href="#12">Wrapping Up</a></li>
</ul></div>
<h2 id="toc-holding-our-breath">Holding Our Breath<a name="1"></a></h2>
<p>So, it turns out that one of <a href="http://quach.blinkdagger.com/about">Quan&#8217;s</a> many talents is the ability to hold his breath for long periods of time. I&#8217;m wondering if I should challenge him to a breath-holding contest &#8211;&gt; whoever holds it longer wins. Since I&#8217;m not sure if I have a chance at beating him, I took some practice breath holds and timed myself.  Here are my results after 40 holds:
         </p>
<pre class="codeinput">load <span class="string">RobPracticeHolds.mat</span>; y = ones(size(breathholds));
h1 = figure(<span class="string">'Position'</span>,[100 100 400 100],<span class="string">'Color'</span>,<span class="string">'w'</span>);
scatter(breathholds,y);
<span class="comment">% using a scatter plot like a dot plot</span>

xlabel(<span class="string">'Seconds'</span>);
set(gca,<span class="string">'Yticklabel'</span>,[]);
title(<span class="string">'Practice Holds'</span>);
</pre>
<p><img vspace="5" hspace="5" src="http://www.blinkdagger.com/wp-content/uploads/2008/Stats/2/dstats_01.png" alt="stats" class="center" /> </p>
<p>You can see that my times go from 40-something to over 120 seconds. I&#8217;m not very consistent. The middle of the dense cluster of times seems to be around 70 seconds, so let&#8217;s call that my &#8220;expected&#8221; time for now. As you can see, viewing these results as a bunch of points has its limitations, so what tools can we employ here to get more precise?</p>
<p><span id="more-158"></span></p>
<p>When it comes to describing a dataset, there are some standardized things to look at before getting &#8220;application specific.&#8221; Descriptors of <b>central tendency</b> seek to locate the data group, typically by finding an estimate of where the middle lies. Next, descriptors of <b>spread</b> explain how widely dispersed or tightly grouped the data is. And lastly, the <b>shape</b> measures how the data looks as a body, usually in terms of a histogram.
         </p>
<h2 id="toc-central-tendency">Central Tendency<a name="3"></a></h2>
<p>For the <b>central tendency</b> of my data, we will look to the <tt>mean</tt>, <tt>median</tt>, and <tt>mode</tt>.  All three may not necessarily apply to our data, so let&#8217;s examine what each of them will return.
         </p>
<p><b><i>Mean</i></b> returns the arithmetic mean, also called the average, of the data. This is probably the most commonly used statistic. It simply sums up all the values and divides by the number of values (giving equal weight to each value in the dataset). Calling <tt>mean(x)</tt> is the same as calling <tt>sum(x)/numel(x)</tt>.
         </p>
<p><b><i>Median</i></b> returns the central value in the dataset. This is simpler than <tt>mean</tt> in that it finds the middle of a sorted list of values. If there are an odd number of values, then the center value <i>is</i> the median value. If there are an even number of values, then a value halfway between the 2 center values is the median value. This is usually different than the mean since asymmetry in the data tends to move the median differently than the mean.
         </p>
<p><b><i>Mode</i></b> returns the most frequently occurring value. If your dataset has more than one most frequently occurring value, then the lowest of them is returned. For small datasets such as mine, it will be unlikely that any values occur more than once. For very large datasets, or data that has been rounded, filtered, or transformed in some way, <tt>mode</tt> can be more meaningful (such as the peak of a histogram).
         </p>
<p>So for my practice breath hold data, I select the <tt>mean</tt> and <tt>median</tt> to describe the central tendency of the dataset. </p>
<pre class="codeinput">
disp([<span class="string">'The mean is '</span>,num2str(mean(breathholds)),<span class="string">' seconds (green line).'</span>]);
disp([<span class="string">'The median is '</span>,num2str(median(breathholds)),<span class="string">' seconds (red line).'</span>]);
hold <span class="string">all</span>;
line([mean(breathholds) mean(breathholds)],[0.5 1.5],<span class="string">'color'</span>,<span class="string">'g'</span>);
line([median(breathholds) median(breathholds)],[0.5 1.5],<span class="string">'color'</span>,<span class="string">'r'</span>);
</pre>
<pre class="codeoutput">
The mean is 74.1834 seconds (green line).
The median is 73.0013 seconds (red line).
</pre>
<p><img vspace="5" hspace="5" src="http://www.blinkdagger.com/wp-content/uploads/2008/Stats/2/dstats_02.png" alt="stats 2" class="center" /> </p>
<p>These are better estimates than my previous &#8220;eyeball&#8221; guess of 70 seconds. So, when I tell Quan how long I tend to hold my breath, I can say something like &#8220;I expect to hold it around 74 seconds&#8221; and see if he laughs. If he doesn&#8217;t laugh, then maybe I have a shot at beating him.</p>
<h2 id="toc-spread">Spread<a name="5"></a></h2>
<p>So let&#8217;s suppose that Quan doesn&#8217;t laugh at me, and maybe I have a chance at holding my breath longer than him. My next concern is whether or not I am consistent enough to have a winning time in our contest. I will only get one try, so how much higher or lower than my center of about 74 seconds should I expect? From my first &#8220;eyeball&#8221; estimate, my times went from 40-something to over 120 seconds. How can we measure the spread more precisely? There are several methods available, so let&#8217;s see what each will return when called:
         </p>
<p><i><b>Std</b></i> returns the <i>standard deviation</i> of the dataset. This is probably the second-most used statistic, behind the <tt>mean</tt>. An overly simplified explanation of <tt>std</tt> is that it takes the average difference between each point and the <tt>mean</tt>. Higher values of <tt>std</tt> indicate that the data is (on average) farther away from the <tt>mean</tt>, and thus more spread out. Low values of <tt>std</tt> indicate tightly grouped data.
         </p>
<p>The <tt>std</tt> equation is much more impressive to look at though, since it squares each point&#8217;s difference from the mean (deviation), sums them up, divides by (n-1), and then takes the square root to &#8220;standardize&#8221; the result.
         </p>
<pre class="codeinput">
h2 = figure(<span class="string">'Position'</span>,[200 200 400 100],<span class="string">'Color'</span>,<span class="string">'w'</span>); axis <span class="string">off</span>;
text(.5,.45,<span class="string">'$$std(x) = \sqrt{\frac{\sum_{i=1}^n(x_i-\bar{x})^2}{n-1}}$$'</span>,<span class="keyword">...</span>
<span class="string">'Interpreter'</span>,<span class="string">'latex'</span>,<span class="string">'HorizontalAlignment'</span>,<span class="string">'Center'</span>,<span class="string">'FontSize'</span>,16);
</pre>
<p><img vspace="5" hspace="5" src="http://www.blinkdagger.com/wp-content/uploads/2008/Stats/2/dstats_03.png" class="center" alt="stats3" /> </p>
<pre class="codeinput">
disp([<span class="string">'The standard deviation of my practice holds is '</span>,<span class="keyword">...</span>
num2str(std(breathholds)),<span class="string">' seconds.'</span>]);
</pre>
<pre class="codeoutput">
The standard deviation of my practice holds is 19.0874 seconds.
</pre>
<p><i><b>Min</b></i>, <i><b>Max</b></i>, and <i><b>Range</b></i> tell you the extents of your data. If your data is representative of the phenomenon being measured, then looking at <tt>min</tt> and <tt>max</tt> give you outer boundaries around what to expect, while <tt>range</tt> describes the width of your data. One weakness of these 3 functions - they are vulnerable to outliers. If you have a wild value in the dataset that is not really representative of what you are studying, they will not catch it. By the way, <tt>range(x)</tt> is just the same as calling <tt>max(x)-min(x)</tt>.
         </p>
<pre class="codeinput">figure(h1);
disp([<span class="string">'My times go from '</span>,num2str(min(breathholds)),<span class="string">' to '</span>,<span class="keyword">...</span>

    num2str(max(breathholds)),<span class="string">' seconds (black lines),'</span>]);
disp([<span class="string">'with a total range of '</span>,num2str(range(breathholds)),<span class="string">' seconds.'</span>]);
line([min(breathholds) min(breathholds)],[0.5 1.5],<span class="string">'color'</span>,<span class="string">'k'</span>);
line([max(breathholds) max(breathholds)],[0.5 1.5],<span class="string">'color'</span>,<span class="string">'k'</span>);
</pre>
<pre class="codeoutput">My times go from 44.8692 to 128.2181 seconds (black lines),
with a total range of 83.3489 seconds.
</pre>
<p><img vspace="5" hspace="5" src="http://www.blinkdagger.com/wp-content/uploads/2008/Stats/2/dstats_04.png" alt="stats4" class="center" /></p>
<p><i><b>IQR</b>, inter-quartile range</i>, is a better estimate of the spread than the range. It measures the width of the 2 inner quarters of the points in the dataset, telling you the bounds which hold half of your data. By ignoring the outer quarters of the dataset, <tt>iqr</tt> is not sensitive to outliers. To find the <tt>iqr</tt> of a dataset, sort it and then select the middle 50% of the points (same as finding the 25% and 75% quantiles). The difference between the values at either end of the middle 50% of points is the inter-quartile range.
         </p>
<pre class="codeinput">quantiles = quantile(breathholds,[.25 .75]);
disp([<span class="string">'The middle 50% of my times are between '</span> ,num2str(quantiles(1)),<span class="keyword">...</span>
    <span class="string">' and '</span>,num2str(quantiles(2))]);
disp([<span class="string">'seconds (blue lines), with an IQR of '</span>,num2str(iqr(breathholds))]);
line([quantiles(1) quantiles(1)],[0.5 1.5],<span class="string">'color'</span>,<span class="string">'b'</span>);
line([quantiles(2) quantiles(2)],[0.5 1.5],<span class="string">'color'</span>,<span class="string">'b'</span>);
</pre>
<pre class="codeoutput">The middle 50% of my times are between 60.6648 and 84.6078
seconds (blue lines), with an IQR of 23.9431
</pre>
<p><img vspace="5" hspace="5" src="http://www.blinkdagger.com/wp-content/uploads/2008/Stats/2/dstats_05.png" class="center" alt="stats5"/></p>
<p>So now I&#8217;m getting a better understanding of what to expect during a breath-holding contest.  It seems most likely that I will hold it for a minute to almost a minute and a half. I wonder if this is competitive?
         </p>
<h2 id="toc-the-5-in-1-tool">The 5-in-1 tool<a name="10"></a></h2>
<p>Before we move on, let&#8217;s look at the &#8220;Swiss Army knife&#8221; of descriptive statistics - <b><tt>boxplot</tt></b>. Most of the things we just reviewed above at are contained in a <tt>boxplot</tt>, plus a bonus feature of <i>outlier protection</i>. That&#8217;s right, <tt>boxplot</tt> does include a simple guarding scheme that identifies any points as outliers that are more than 1.5 times the <tt>iqr</tt> away from the box. Pretty cool. Let&#8217;s take a look at what we have constructed on our <tt>scatter</tt> plot compared to a real <tt>boxplot</tt>.
         </p>
<pre class="codeinput">title(<span class="string">'Scatter with Min, 25%iqr, Median, Mean, 75%iqr, &amp; Max lines'</span>);
xlabel(<span class="string">''</span>);
h3 = figure(<span class="string">'Position'</span>,[100 100 400 100],<span class="string">'Color'</span>,<span class="string">'w'</span>);
boxplot(breathholds,<span class="string">'orientation'</span>,<span class="string">'horizontal'</span>,<span class="string">'widths'</span>,.5);
set(gca,<span class="string">'XLim'</span>,[40 140]); title(<span class="string">'A Boxplot of the same data'</span>);
xlabel(<span class="string">''</span>); set(gca,<span class="string">'Yticklabel'</span>,[]); ylabel(<span class="string">''</span>);
</pre>
<p><img vspace="5" hspace="5" src="http://www.blinkdagger.com/wp-content/uploads/2008/Stats/2/dstats_06.png" alt="stats6" class="center"/><br />
 <img vspace="5" hspace="5" src="http://www.blinkdagger.com/wp-content/uploads/2008/Stats/2/dstats_07.png" alt="stats7" class="center"/></p>
<p>When we line-up the two plots, see how the <tt>boxplot</tt> automatically contains visual representations of the <tt>min</tt> (left whisker), <tt>iqr</tt> (blue box), <tt>median</tt> (red line), and <tt>max</tt> (right whisker)? But wait! Something is different with the right whisker - our <tt>max</tt> from the scatter plot was identified by the <tt>boxplot</tt> as an outlier, since it sits more than 1.5 x <tt>iqr</tt> away from the box. So <tt>boxplot</tt> marked it with a red &#8216;+&#8217; and then reset the &#8216;whisker&#8217; to the <i>apparent max</i> of the next lower point.
         </p>
<p>When you know how to read a <tt>boxplot</tt>, it is a very efficient way to summarize the <b>central tendency</b> and <b>spread</b> of your dataset. It only lacks the <tt>mean</tt> and <tt>std</tt>, which are substitutes for the <tt>median</tt> and <tt>iqr</tt> in this case.
         </p>
<h2 id="toc-wrapping-up">Wrapping Up<a name="12"></a></h2>
<p>So after all the analysis of my practice data, I&#8217;m not very confident about beating Quan in a breath-holding contest. Maybe after more practice and the proper coaching, I&#8217;ll have a chance. <img src='http://www.blinkdagger.com/wp-includes/images/smilies/icon_wink.gif' alt=';-)' class='wp-smiley' />
         </p>
<p>In our next segment, we will finish up descriptive stats with a look at <b>shape</b> and some more visualization techniques. If there are specific topics you would like to see covered in future posts, please leave a comment below. And, as always, questions are quite welcome.
         </p>
<p>a</p>
<p><a href="http://www.blinkdagger.com/matlab/intro-to-statistics-descriptive-statistics">Intro to Statistics: Descriptive Statistics</a></p>
<img src="http://feeds.feedburner.com/~r/blinkdaggerMatlab/~4/303568202" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.blinkdagger.com/matlab/intro-to-statistics-descriptive-statistics/feed</wfw:commentRss>
		<feedburner:origLink>http://www.blinkdagger.com/matlab/intro-to-statistics-descriptive-statistics</feedburner:origLink></item>
		<item>
		<title>Monday Math Madness #7</title>
		<link>http://feeds.feedburner.com/~r/blinkdaggerMatlab/~3/298890353/monday-math-madness-7</link>
		<comments>http://www.blinkdagger.com/matlab/monday-math-madness-7#comments</comments>
		<pubDate>Tue, 27 May 2008 06:43:43 +0000</pubDate>
		<dc:creator>Daniel Sutoyo</dc:creator>
		
		<category><![CDATA[MATLAB]]></category>

		<category><![CDATA[monday math madness]]></category>

		<category><![CDATA[feedback]]></category>

		<guid isPermaLink="false">http://www.blinkdagger.com/?p=157</guid>
		<description><![CDATA[Hope everyone had a good long weekend. We have a brand new contest rolling over at Sol&#8217;s blog wildaboutmath.com! His love for infinite series is found in this edition of Monday Math Madness. Sol claims it’s challenging but not brutally difficult, so give it a try. He won’t reveal the source until the contest ends [...]]]></description>
			<content:encoded><![CDATA[<p><img src="/wp-content/uploads/2008/MMM/mmm.jpg" alt="mmm.jpg" title="mmm.jpg" width="500" height="100" vspace="10" border="0" /></p>
<p>Hope everyone had a good long weekend. We have a brand new contest rolling over at Sol&#8217;s blog <a href="http://wildaboutmath.com/2008/05/26/monday-math-madness-7/">wildaboutmath.com</a>! His love for infinite series is found in this edition of Monday Math Madness. Sol claims it’s challenging but not brutally difficult, so give it a try. He won’t reveal the source until the contest ends because the answer is posted with the problem.</p>
<p>Thanks to the sponsors for this contest, he has one $25 gift certificate left for the A<a href="http://www.artofproblemsolving.com/">rt of Problem Solving</a>. He also has a couple of Rubik’s Revolutions, courtesy of <a href="http://www.technosourceusa.com/products.htm">Techno Source</a>. Depending on how many correct solutions he gets he may give away two prizes!</p>
<h2 id="toc-wanted-feedback">Wanted Feedback!</h2>
<p>Sol, Quan, and I have been enjoying hosting these contests. We love to hear suggestions and comments to make these more entertaining. So let us know if you have something to share. </p>
<p>Our older MATLAB tutorials are consistently being searched on google, and it is a great encouragement to hear people finding them useful. Recently we have our guest blogger Rob Slazas who posted his <a href="http://www.blinkdagger.com/matlab/intro-to-statistics-matlab-style">Intro to Statistics in MATLAB</a>. Please take a look if you haven&#8217;t and post any requests you may have!</p>
<p>a</p>
<p><a href="http://www.blinkdagger.com/matlab/monday-math-madness-7">Monday Math Madness #7</a></p>
<img src="http://feeds.feedburner.com/~r/blinkdaggerMatlab/~4/298890353" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.blinkdagger.com/matlab/monday-math-madness-7/feed</wfw:commentRss>
		<feedburner:origLink>http://www.blinkdagger.com/matlab/monday-math-madness-7</feedburner:origLink></item>
		<item>
		<title>Intro to Statistics - MATLAB Style</title>
		<link>http://feeds.feedburner.com/~r/blinkdaggerMatlab/~3/298890354/intro-to-statistics-matlab-style</link>
		<comments>http://www.blinkdagger.com/matlab/intro-to-statistics-matlab-style#comments</comments>
		<pubDate>Tue, 20 May 2008 09:38:11 +0000</pubDate>
		<dc:creator>Rob Slazas</dc:creator>
		
		<category><![CDATA[MATLAB]]></category>

		<category><![CDATA[statistics]]></category>

		<guid isPermaLink="false">http://www.blinkdagger.com/?p=155</guid>
		<description><![CDATA[Blinkdagger is proud to have Rob Slazas, a R&#038;D engineer and 6-sigma blackbelt, to head up a new series on statistics in MATLAB. This series will run in tangent with Quan&#8217;s Fourier series. If you have requests and comments on statistics, please leave Rob a comment!

MATLAB and the Statistics Toolbox have a nice complement of [...]]]></description>
			<content:encoded><![CDATA[<p><em>Blinkdagger is proud to have Rob Slazas, a R&#038;D engineer and 6-sigma blackbelt, to head up a new series on <strong>statistics in MATLAB</strong>. This series will run in tangent with Quan&#8217;s Fourier series. If you have requests and comments on statistics, please leave Rob a comment!</em></p>
<p><img src="http://www.blinkdagger.com/tutorials/matlab/matlab-icon.jpg" align = "left" alt="Matlab Logo" hspace = "10"  />
<p>MATLAB and the Statistics Toolbox have a nice complement of functions useful in statistical analyses.  For our first look into this area, let&#39;s get a mile-high view of the different function categories and how they are used.
         </p>
<p>Like all things MATLAB, they benefit from the <b>power</b> of the language being infinitely customizable, and the <b>genius</b> of the file exchange to borrow from those who have solved before you.  Some folks say the stat functions&#39; output are not as polished as those from a dedicated, commercial stat package.  But in our survey below, I think you&#39;ll find nearly everything you need is either included, available at the FeX, or a short bit of code away.
         </p>
<p><span id="more-155"></span></p>
<h2 id="toc-a-little-background">A Little Background<a name="0.2_2"></a></h2>
<p>Just to make sure we&#39;re on the same page here, what are &#39;Statistics&#39; anyway?  Philosophies vary, but at the heart of it stats are a collection of mathematical procedures (tools) meant to help us make decisions or answer a question using imperfect or incomplete data.
         </p>
<p>Statistics are also (in)famous for being misused, since they are susceptible to the selection bias of the user.  The most common problems are applying statistical tools to a question that they really aren&#39;t capable of answering, or analyzing only the favorable data. When you run a procedure on data, it will still return an &quot;answer&quot; whether it is appropriate or not.
         </p>
<p>I like the way <a href="http://en.wikipedia.org/wiki/Tukey" target="_blank">Tukey</a> (a great 20th century mathematician) said it:
         </p>
<p><img vspace="5" hspace="5" src="http://upload.wikimedia.org/wikipedia/en/e/e9/John_Tukey.jpg"> </p>
<pre>   &quot;Far better an approximate answer to the right question, which is often vague,
 than an exact answer to the wrong question, which can always be made precise.&quot;</pre>
<h2 id="toc-types-of-stat-functions">Types of Stat Functions<a name="0.2_5"></a></h2>
<p>All of the main categories of stat functions are represented in the Statistics Toolbox.  In the MATLAB help you&#39;ll find a great bit of detail on their usage. You may also find that some of these functions are more &quot;mainstream&quot; than others.  I would say - if you haven&#39;t heard of a particular function before, caveat emptor!  Crack a book first and make sure you will get what you intend from using it.
         </p>
<p>Now some detail about the contents of the Statistics Toolbox&#8230;</p>
<h2 id="toc-descriptive-statistics">Descriptive Statistics<a name="0.2_6"></a></h2>
<p>Descriptive statistics tell you particular things about the data that you have on hand, and nothing more. Common descriptive statistics are the <tt>mean</tt>, <tt>median</tt>, <tt>mode</tt>, <tt>min</tt> value, <tt>max</tt> value, <tt>range</tt>, and <tt>std</tt> (standard deviation).
         </p>
<h2 id="toc-inferential-statistics">Inferential Statistics<a name="0.2_7"></a></h2>
<p>Inferential statistics attempt to take your data a step further and draw some conclusion(s).  Most functions add your data to a set of assumptions, and return a result that does more than just describe the dataset.  This strategy can be very economic and powerful, since it allows you to employ <b>data sampling</b> instead of gathering very large amounts of data.  Of course the danger is that the assumptions of the function are not appropriate for your data, in which case you could be mislead.
         </p>
<p>One of the most common assumptions is that data comes from a &quot;normally distributed&quot; population.  Since the characteristics of the Normal distribution are well understood, only a small sampling of data is needed to make inferences about the entire population of data from which the sample came.  Not all functions make this assumption, but those that do benefit from leveraging a huge amount of previous work.
         </p>
<p>The categories of inferential statistics functions in MATLAB are:</p>
<div>
<ul>
<li>Hypothesis Testing</li>
<li>Regression</li>
<li>Multivariate Methods</li>
<li>Cluster Analysis</li>
<li>Probability Distributions</li>
<li>Markov Models</li>
<li>Statistical Process Control (SPC)</li>
<li>Analysis of Variance (ANOVA)</li>
<li>Design of Experiments (DOE)</li>
</ul></div>
<h2 id="toc-statistical-visualization">Statistical Visualization<a name="0.2_8"></a></h2>
<p>Like most things, visualization (pretty graphs) is the &quot;cool&quot; part of the toolbox. Some things just seem to make sense immediately when graphed, so these make excellent communication tools. As you might expect, MATLAB does not disappoint in the visualization             department. With no less than 46 functions dedicated to statistical visualization, and the ability to programmatically change the output, we are well taken care of here.
         </p>
<p>Worth mentioning are some of my favorites, with a selection displayed below with dummy data: <tt>histfit</tt> (draws a histogram of your data with a normal curve fit overlaid), <tt>boxplot</tt>, <tt>wblplot</tt> (Weibull distribution probability plot), <tt>randtool</tt> (an interactive random number generator), and <tt>polytool</tt> (an interactive polynomial fitting tool).         </p>
<pre>fudge = repmat(1:4,30,1); dat = randn(30,4).*fudge+3*sin(fudge<WBR>);
figure(<span>&#39;Position&#39;</span>,[100 100 600 300]);subplot(1,2,1);histfit<WBR>(dat(:));
subplot(1,2,2);boxplot(dat,<span>&#39;notch&#39;</span>,<span>&#39;on&#39;</span>);
</pre>
<p><img vspace="5" hspace="5" src="http://www.blinkdagger.com/wp-content/uploads/2008/Stats/statintro_01.png"><br />
<h2 id="toc-the-other-functions">The &quot;Other&quot; Functions<a name="0.2_9"></a></h2>
<p>Bringing up the tail end of the toolbox is a collection of helpful things for handling data and making GUI&#39;s.  They fall into the following categories of function:
         </p>
<div>
<ul>
<li>File I/O</li>
<li>Organizing Data</li>
<li>Classification</li>
<li>Graphical User Interfaces</li>
<li>Utility Functions</li>
</ul></div>
<p>These can be particularly useful for aggregating large amounts of data, or for datasets with relationships that are important to preserve.
         </p>
<h2 id="toc-wrapping-up">Wrapping Up<a name="0.2_10"></a></h2>
<p>If you are new to statistics, or just new to statistics in MATLAB, hopefully this overview helps you dig in a little more. Those of you who want to see specific applications or functions covered in a future blog post, please reply below with your suggestions.
         </p>
<p>a</p>
<p><a href="http://www.blinkdagger.com/matlab/intro-to-statistics-matlab-style">Intro to Statistics - MATLAB Style</a></p>
<img src="http://feeds.feedburner.com/~r/blinkdaggerMatlab/~4/298890354" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.blinkdagger.com/matlab/intro-to-statistics-matlab-style/feed</wfw:commentRss>
		<feedburner:origLink>http://www.blinkdagger.com/matlab/intro-to-statistics-matlab-style</feedburner:origLink></item>
	</channel>
</rss>
