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

<channel>
	<title>MATLAB Programming blog</title>
	<atom:link href="http://msbs.ca/matlab/?feed=rss2" rel="self" type="application/rss+xml" />
	<link>http://msbs.ca/matlab</link>
	<description>MATLAB tips and tricks for beginner and advanced MATLAB users</description>
	<lastBuildDate>Thu, 19 Jun 2008 01:11:03 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.4</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>MATLAB Consulting for Data Analysis and Statistics</title>
		<link>http://msbs.ca/matlab/?p=25</link>
		<comments>http://msbs.ca/matlab/?p=25#comments</comments>
		<pubDate>Thu, 19 Jun 2008 01:09:02 +0000</pubDate>
		<dc:creator>Simon</dc:creator>
				<category><![CDATA[Advanced MATLAB]]></category>
		<category><![CDATA[Beginner MATLAB]]></category>
		<category><![CDATA[MATLAB GUIDE programming]]></category>
		<category><![CDATA[compiling]]></category>
		<category><![CDATA[consultants]]></category>
		<category><![CDATA[consulting]]></category>
		<category><![CDATA[development]]></category>
		<category><![CDATA[efficient]]></category>
		<category><![CDATA[GUIDE]]></category>
		<category><![CDATA[Kalman]]></category>
		<category><![CDATA[MATLAB]]></category>
		<category><![CDATA[sensors]]></category>
		<category><![CDATA[signal processing]]></category>
		<category><![CDATA[statistics]]></category>

		<guid isPermaLink="false">http://msbs.ca/matlab/?p=25</guid>
		<description><![CDATA[Our team is available for MATLAB development consultation.  We have created our own set of tools for

Digital signal processing (DSP) &#8211; Analysis of data from motion sensors (accelerometers, gyroscopes, magnetometers), force plates, audio.  Also, we have considerable background in different filter types including IIR and FIR digital filters, zero-phase filtering, and Kalman filters.
Statistics &#8211; We [...]]]></description>
			<content:encoded><![CDATA[<p>Our team is available for MATLAB development consultation.  We have created our own set of tools for</p>
<ul>
<li>Digital signal processing (DSP) &#8211; Analysis of data from motion sensors (accelerometers, gyroscopes, magnetometers), force plates, audio.  Also, we have considerable background in different filter types including IIR and FIR digital filters, zero-phase filtering, and Kalman filters.</li>
<li>Statistics &#8211; We can analyze any set of data for correlation or regression equations.</li>
<li>Interface development (GUIDE) for your functions</li>
<li>Compiling your interfaces or functions for distribution</li>
<li>General MATLAB development efficiency tools</li>
</ul>
<p><a title="Contact MSB Solutions" href="http://msbs.ca/contact.php">Contact us</a> for more information or a quote for your project from one of our consultants.</p>
]]></content:encoded>
			<wfw:commentRss>http://msbs.ca/matlab/?feed=rss2&amp;p=25</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Element by element arithmetic operators in MATLAB</title>
		<link>http://msbs.ca/matlab/?p=18</link>
		<comments>http://msbs.ca/matlab/?p=18#comments</comments>
		<pubDate>Mon, 28 Jan 2008 19:53:19 +0000</pubDate>
		<dc:creator>Simon</dc:creator>
				<category><![CDATA[Beginner MATLAB]]></category>
		<category><![CDATA[arrays]]></category>
		<category><![CDATA[element]]></category>
		<category><![CDATA[MATLAB]]></category>
		<category><![CDATA[matrices]]></category>
		<category><![CDATA[matrix]]></category>
		<category><![CDATA[multiplication]]></category>
		<category><![CDATA[point wise]]></category>
		<category><![CDATA[pointwise]]></category>

		<guid isPermaLink="false">http://msbs.ca/matlab/beginner-matlab/element-by-element-arithmetic-operators-in-matlab/</guid>
		<description><![CDATA[One of the most important basics of MATLAB is to understand how to use element-by-element (or &#8220;point-wise&#8221;) arithmetic operators for multiplying arrays or matrices.  The following are some examples of the logic behind the element-by-element operator, and you are expected to understand basic linear algebra for this to make sense.

Notice (in the first example) [...]]]></description>
			<content:encoded><![CDATA[<p>One of the most important basics of MATLAB is to understand how to use element-by-element (or &#8220;point-wise&#8221;) arithmetic operators for multiplying arrays or matrices.  The following are some examples of the logic behind the element-by-element operator, and you are expected to understand <a href="http://en.wikipedia.org/wiki/Matrix_multiplication" title="basic linear algebra">basic linear algebra</a> for this to make sense.</p>
<p align="center"><img src="http://msbs.ca/matlab/_images/element-wise-multiplication.gif" alt="Element-wise multiplication" border="0" height="230" width="420" /></p>
<p>Notice (in the first example) that [1 3 7]*[1; 3; 7] could be written as [1 3 7]*[1 3 7]<strong>&#8216;</strong>.  Notice in the third example that [1 3 7]*[1 3 7] could be written as [1 3 7]^2 which will also produce an error.</p>
<p>I think this these examples are fairly self-explanatory, but just understand your goals keeping what you learned in math class in mind. You can access MATLAB&#8217;s documentation for the element-by-element operator by typing &#8220;doc&#8221;, and searching for &#8220;arithmetic operators&#8221;.</p>
]]></content:encoded>
			<wfw:commentRss>http://msbs.ca/matlab/?feed=rss2&amp;p=18</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Subplots in MATLAB GUIDE using panels instead of axes</title>
		<link>http://msbs.ca/matlab/?p=16</link>
		<comments>http://msbs.ca/matlab/?p=16#comments</comments>
		<pubDate>Thu, 03 Jan 2008 19:40:07 +0000</pubDate>
		<dc:creator>Simon</dc:creator>
				<category><![CDATA[Beginner MATLAB]]></category>
		<category><![CDATA[MATLAB GUIDE programming]]></category>

		<guid isPermaLink="false">http://msbs.ca/matlab/beginner-matlab/subplots-in-matlab-guide-using-panels-instead-of-axes/</guid>
		<description><![CDATA[If you have ever been confused with using subplots in MATLAB GUIDE, you are not alone.  Using an axes object does not allow for subplots like in a regular MATLAB function or script.  Here is a workaround:

In your interface, use a &#8220;panel&#8221;  instead of an &#8220;axes&#8221;.
Set your panel&#8217;s tag name to &#8220;pnlMyPlot&#8221;
In [...]]]></description>
			<content:encoded><![CDATA[<p>If you have ever been confused with using subplots in MATLAB GUIDE, you are not alone.  Using an axes object does not allow for subplots like in a regular MATLAB function or script.  Here is a workaround:</p>
<ol>
<li>In your interface, use a &#8220;panel&#8221;  instead of an &#8220;axes&#8221;.</li>
<li>Set your panel&#8217;s tag name to &#8220;pnlMyPlot&#8221;</li>
<li>In your code, identify your plot target with<br />
<code>subplot(1,1,1,'Parent',handles.pnlMyPlot)</code></li>
<li>Then, code your plot or subplot like normal.  For example:<br />
<code>subplot(2,1,1)<br />
hold on<br />
plot(rand(10,1))<br />
ylabel('Y axis label')<br />
xlabel('X axis label')<br />
title('10 random numbers')<br />
hold off</code></li>
</ol>
<p>The attached example demonstrates using a panel instead of an axes for plotting in your interface.  If you look at the code for each button, try uncommenting the code for a logical subplot using an axes, and check out what happens.  Extract the two files into your MATLAB work directory.  <a href="http://msbs.ca/matlab/wp-content/uploads/2008/01/subplots_in_guide.zip" title="Subplots in GUIDE example">Subplots in GUIDE example</a></p>
]]></content:encoded>
			<wfw:commentRss>http://msbs.ca/matlab/?feed=rss2&amp;p=16</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Take advantage of MATLAB shortcuts</title>
		<link>http://msbs.ca/matlab/?p=15</link>
		<comments>http://msbs.ca/matlab/?p=15#comments</comments>
		<pubDate>Thu, 03 Jan 2008 03:09:53 +0000</pubDate>
		<dc:creator>Simon</dc:creator>
				<category><![CDATA[Beginner MATLAB]]></category>
		<category><![CDATA[cuts]]></category>
		<category><![CDATA[MATLAB]]></category>
		<category><![CDATA[quit debugging]]></category>
		<category><![CDATA[R2007a]]></category>
		<category><![CDATA[R2007b]]></category>
		<category><![CDATA[short]]></category>
		<category><![CDATA[shortcuts]]></category>

		<guid isPermaLink="false">http://msbs.ca/matlab/beginner-matlab/take-advantage-of-matlab-shortcuts/</guid>
		<description><![CDATA[The top left of the MATLAB window allows for quick shortcuts.  Any scripts or functions you use frequently should be there for convenience.  (You don&#8217;t type in your favorite websites all the time; you use bookmarks!)  This tutorial will show you my most common shortcuts and how to make your own.
To make [...]]]></description>
			<content:encoded><![CDATA[<p>The top left of the MATLAB window allows for quick shortcuts.  Any scripts or functions you use frequently should be there for convenience.  (You don&#8217;t type in your favorite websites all the time; you use bookmarks!)  This tutorial will show you my most common shortcuts and how to make your own.</p>
<p>To make a shortcut, just right-click to the right of &#8220;Shortcuts&#8221; and choose &#8220;New Shortcut&#8221;.  Give your shortcut a logical name (&#8221;Label&#8221;) and enter all the function calls or scripts in the callback.</p>
<p>The five most frequently used shortcuts in my workspace are:</p>
<ol>
<li>Blank everything<br />
Label: &#8220;Blank&#8221;<br />
Callback:<br />
<code>clear all<br />
close all<br />
clc</code></li>
<li>Clear variables<br />
Label: &#8220;Clear vars&#8221;<br />
Callback:<br />
<code>clear all</code></li>
<li>Clear Command Window<br />
Label: &#8220;Clear CW&#8221;<br />
Callback:<br />
<code>clc</code></li>
<li>Close all figures<br />
Label: &#8220;Close figures&#8221;<br />
Callback:<br />
<code>close all</code></li>
<li>Stop debugging<br />
Label: &#8220;Stop debugging&#8221;<br />
Callback:<br />
<code>dbquit</code></li>
</ol>
]]></content:encoded>
			<wfw:commentRss>http://msbs.ca/matlab/?feed=rss2&amp;p=15</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Dark theme for MATLAB</title>
		<link>http://msbs.ca/matlab/?p=14</link>
		<comments>http://msbs.ca/matlab/?p=14#comments</comments>
		<pubDate>Wed, 02 Jan 2008 20:01:24 +0000</pubDate>
		<dc:creator>Simon</dc:creator>
				<category><![CDATA[Beginner MATLAB]]></category>
		<category><![CDATA[dark]]></category>
		<category><![CDATA[editor]]></category>
		<category><![CDATA[font]]></category>
		<category><![CDATA[MATLAB]]></category>
		<category><![CDATA[theme]]></category>

		<guid isPermaLink="false">http://msbs.ca/matlab/beginner-matlab/dark-theme-for-matlab/</guid>
		<description><![CDATA[
As of MATLAB R2007b, there is no quick way to create/enable different themes for your editor; however, we can still manually change settings. For some reason, I&#8217;m obsessed with dark backgrounds, light text, and simplistic fonts, so if you want to try different (better) settings, here are my personal settings.
To get your workspace similar to [...]]]></description>
			<content:encoded><![CDATA[<p style="text-align: center"><a href="http://msbs.ca/matlab/_images/dark-theme-full.gif" title="MATLAB dark theme"><img src="http://msbs.ca/matlab/_images/dark-theme.gif" alt="MATLAB dark theme" border="0" height="400" hspace="10" vspace="10" width="440" /></a></p>
<p>As of MATLAB R2007b, there is no quick way to create/enable different themes for your editor; however, we can still manually change settings. For some reason, I&#8217;m obsessed with dark backgrounds, light text, and simplistic fonts, so if you want to try different (better) settings, here are my personal settings.</p>
<p>To get your workspace similar to mine, follow these steps:</p>
<ul>
<li>Get the <a href="http://dejavu.sourceforge.net/wiki/index.php/Main_Page" title="DejaVuWiki" target="_blank">DejaVu font family</a>
<ul>
<li>If you have Windows, get the latest package as a zip archive.</li>
</ul>
<ul>
<li>Open your &#8220;Fonts&#8221; folder (Start / Control Panel / Fonts)</li>
<li>Open your zip file of TrueType fonts, and find the &#8220;ttf&#8221; folder.</li>
<li>Copy everything in the &#8220;ttf&#8221; folder to your &#8220;Fonts&#8221; folder</li>
</ul>
</li>
<li>In MATLAB, go to File / Preferences&#8230;
<ul>
<li>Click &#8220;Fonts&#8221; on the left</li>
<li>Set your &#8220;Desktop code font&#8221; settings to DejaVu Sans Mono, Plain, 10 (code should be mono-spaced so everything aligns nicely)</li>
<li>Set your &#8220;Desktop text font&#8221; settings to DejaVu Sans, Plain, 10</li>
</ul>
</li>
<li>Stay in &#8220;Preferences&#8221;.  Below &#8220;Fonts&#8221; open &#8220;Colors&#8221;.
<ul>
<li>Click the dropdown for &#8220;Text&#8221;; choose &#8220;More Colors&#8230;&#8221;; click &#8220;RGB&#8221; top right; make Red, Green, and Blue <strong>240</strong>; click &#8220;OK&#8221;.</li>
<li>Click the dropdown for &#8220;Background&#8221;; choose &#8220;More Colors&#8230;&#8221;; click &#8220;RGB&#8221; top right; make Red, Green, and Blue <strong>10</strong>; click &#8220;OK&#8221;.</li>
<li>Enable &#8220;M-Lint autofix highlight&#8221;; click the dropdown for it; choose &#8220;More Colors&#8230;&#8221;; click &#8220;RGB&#8221; top right; make Red, Green, and Blue <strong>63</strong>; click &#8220;OK&#8221;.</li>
</ul>
</li>
<li>Stay in &#8220;Preferences&#8221;.  In &#8220;Editor/Debugger&#8221;, choose &#8220;Display&#8221;.
<ul>
<li>Enable &#8220;Highlight current line&#8221;; select the dropdown for it; choose &#8220;More Colors&#8230;&#8221;; click &#8220;RGB&#8221; top right; make Red <strong>10</strong>, Green <strong>36</strong>, and Blue <strong>106</strong>; click &#8220;OK&#8221;.</li>
<li>Enable &#8220;Highlight cells&#8221;; select the dropdown for it; choose &#8220;More Colors&#8230;&#8221;; click &#8220;RGB&#8221; top right; make Red, Green, and Blue <strong>26</strong>; click &#8220;OK&#8221;.</li>
</ul>
</li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://msbs.ca/matlab/?feed=rss2&amp;p=14</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>How to properly use cell arrays in MATLAB</title>
		<link>http://msbs.ca/matlab/?p=13</link>
		<comments>http://msbs.ca/matlab/?p=13#comments</comments>
		<pubDate>Tue, 18 Dec 2007 21:38:10 +0000</pubDate>
		<dc:creator>Simon</dc:creator>
				<category><![CDATA[Beginner MATLAB]]></category>
		<category><![CDATA[array]]></category>
		<category><![CDATA[arrays]]></category>
		<category><![CDATA[cell]]></category>
		<category><![CDATA[cell array]]></category>
		<category><![CDATA[cells]]></category>
		<category><![CDATA[MATLAB]]></category>

		<guid isPermaLink="false">http://msbs.ca/matlab/beginner-matlab/how-to-properly-use-cell-arrays-in-matlab/</guid>
		<description><![CDATA[Cell arrays are tricky for most people to get their heads around when programming MATLAB. Cells are very similar to arrays, but they can contain numbers, strings, or arrays themselves.  I use cells primarily when I want to export data to Excel; here&#8217;s a quick example:
data = cell(3,2);
data{1,1} = 'Data series 1';
data{1,2} = 'Data [...]]]></description>
			<content:encoded><![CDATA[<p>Cell arrays are tricky for most people to get their heads around when programming MATLAB. Cells are very similar to arrays, but they can contain numbers, strings, or arrays themselves.  I use cells primarily when I want to export data to Excel; here&#8217;s a quick example:</p>
<pre>data = cell(3,2);
data{1,1} = 'Data series 1';
data{1,2} = 'Data series 2';
data{2,1} = 1;
data{2,2} = 2;
data{3,1} = 3;
data{3,2} = 4;
data
xlswrite('myDataInExcel',data)</pre>
<p>To learn how to use cell arrays properly, and understand the differences, type the following commands into your MATLAB window:</p>
<pre>%% Make an array
myArray = zeros(3,1);
myArray(1) = pi;

%% Invalid assignment - can't put text in an array
myArray(2) = 'This is some text';

%% Another invalid assignment - can't put arrays in arrays
myArray(3) = rand(6,1);

%% Make a cell array
myCell = cell(3,1);
myCell{1} = pi;  % notice the curly braces
myCell{2} = 'This is some text';
myCell{3} = rand(6,1);
myCell  % display it

% accessing information from a cell
number_from_cell = myCell{1} % notice the curly braces
text_from_cell = myCell{2}
array_from_cell = myCell{3}

% notice the difference when you index the cell without curly braces:
number_from_cell = myCell(1)  % notice what happens when you use parenthesis
text_from_cell = myCell(2)
array_from_cell = myCell(3)</pre>
<p>Remember that if you want your number in the cell array, but in text form, &#8220;sprintf&#8221; is really easy:</p>
<pre>myCell{2} = sprintf('%g',pi) % quick example</pre>
<p>I hope these examples demonstrate proper cell array creation and indexing.<span id="more-13"></span></p>
]]></content:encoded>
			<wfw:commentRss>http://msbs.ca/matlab/?feed=rss2&amp;p=13</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Automatic MATLAB function template</title>
		<link>http://msbs.ca/matlab/?p=10</link>
		<comments>http://msbs.ca/matlab/?p=10#comments</comments>
		<pubDate>Tue, 18 Dec 2007 00:49:54 +0000</pubDate>
		<dc:creator>Simon</dc:creator>
				<category><![CDATA[Beginner MATLAB]]></category>
		<category><![CDATA[default]]></category>
		<category><![CDATA[function]]></category>
		<category><![CDATA[help]]></category>
		<category><![CDATA[MathWorks]]></category>
		<category><![CDATA[MATLAB]]></category>
		<category><![CDATA[template]]></category>

		<guid isPermaLink="false">http://msbs.ca/matlab/beginner-matlab/automatic-matlab-function-template/</guid>
		<description><![CDATA[Ever notice how nice looking MathWorks&#8217; m files are?  It&#8217;s because they use a good template.  After a little digging, now you can use an automatic template like the people at MathWorks do.  Let&#8217;s set you up

Get newfun.m with supporting files and extract them to somewhere in your work directory
Modify &#8220;MSB_template.m&#8221; for [...]]]></description>
			<content:encoded><![CDATA[<p>Ever notice how nice looking MathWorks&#8217; m files are?  It&#8217;s because they use a good template.  After a little digging, now you can use an automatic template like the people at MathWorks do.  Let&#8217;s set you up</p>
<ol>
<li>Get <a href="http://msbs.ca/matlab/wp-content/uploads/2007/12/newfun1.zip" title="newfun.m and supporting files">newfun.m with supporting files</a> and extract them to somewhere in your work directory</li>
<li>Modify &#8220;MSB_template.m&#8221; for your own name and company.</li>
</ol>
<p>Next time you&#8217;re writing a new function (eg. myFunction which &#8220;Computes something&#8221;), start with this:</p>
<pre>newfun('myFunction','Computes something')</pre>
<p>Make sure to fill in a logical description, your inputs and outputs, make an example (if possible), and add some similar MATLAB functions to your &#8220;See also&#8221; section.</p>
<p>Here&#8217;s an example of one of my completed functions originally built with &#8220;newfun(&#8217;gen_sin&#8217;,'Make a sine wave&#8217;)&#8221;:</p>
<pre>function output = gen_sin(f,fs,N)
%GEN_SIN  Make a sine wave
%   output = gen_sin(f,fs,N)
%
%   Description:
%     Create a frequency "f" of sampling rate "fs" of "N" many samples
%
%   Inputs:
%          f: frequency
%         fs: sampling rate
%          N: number of samples
%
%   Outputs:
%     output: generated frequency
%
%   Example
%     x = gen_sin(3,100,40); % make 3Hz with Fs of 100Hz, and 40 samples
%     plot(x);
%
%   See also GEN_NOISE

% Author: Simon
% Created: Dec 2005
% Copyright MSB Solutions 2005

ts = 1/fs;
t = ts*(0:N-1)';
output = sin(2*pi*f*t);</pre>
]]></content:encoded>
			<wfw:commentRss>http://msbs.ca/matlab/?feed=rss2&amp;p=10</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Making an installer for your compiled MATLAB GUI&#8217;s</title>
		<link>http://msbs.ca/matlab/?p=8</link>
		<comments>http://msbs.ca/matlab/?p=8#comments</comments>
		<pubDate>Mon, 17 Dec 2007 22:05:13 +0000</pubDate>
		<dc:creator>Simon</dc:creator>
				<category><![CDATA[Advanced MATLAB]]></category>
		<category><![CDATA[MATLAB GUIDE programming]]></category>
		<category><![CDATA[compiled]]></category>
		<category><![CDATA[compiler]]></category>
		<category><![CDATA[installation]]></category>
		<category><![CDATA[installer]]></category>
		<category><![CDATA[MATLAB]]></category>
		<category><![CDATA[NSIS]]></category>
		<category><![CDATA[Nullsoft]]></category>

		<guid isPermaLink="false">http://msbs.ca/matlab/?p=8</guid>
		<description><![CDATA[When distributing your compiled MATLAB application, you may want an installer for the target computer if you have special settings (or simply want to include a Start Menu shortcut and Uninstaller).  An installer allows you to control where the application is installed to and allows you to include any files you want with your [...]]]></description>
			<content:encoded><![CDATA[<p>When distributing your compiled MATLAB application, you may want an installer for the target computer if you have special settings (or simply want to include a Start Menu shortcut and Uninstaller).  An installer allows you to control where the application is installed to and allows you to include any files you want with your application.  Here, we will show you how to write your own installer using Nullsoft&#8217;s NSIS (Nullsoft Scriptable Install System).   Here are the steps to get you going:</p>
<ol>
<li>Get NSIS here: <a href="http://nsis.sourceforge.net/Main_Page" title="http://nsis.sourceforge.net/Main_Page">http://nsis.sourceforge.net/Main_Page</a></li>
<li>Get <a href="http://msbs.ca/matlab/wp-content/uploads/2007/12/matlab_installer_example.nsi" title="my example .nsi file">my example .nsi file</a> (written out below)</li>
<li>Put my example .nsi file, your compiled .exe, your compiled .ctf, and the MCRInstaller X.X.exe in the same folder</li>
<li>Modify the example .nsi file for your application and your company name</li>
<li>Test it out.  I recommend commenting out the section for the MCRInstaller using semicolons (;) at the beginning of each line for that section.</li>
<li>Right click on the .nsi file, and choose &#8220;Compile NSIS Script&#8221;.  (You can do this manually by opening Start / All Programs / NSIS / MakeNSISW (Compiler GUI) &#8211; and following the instructions)</li>
<li>Run the generated installer, and check that everything works OK.</li>
<li>Uninstall your application</li>
<li>Uncomment the MCRInstaller section (remove the semicolons from the start of the line), and do #6 again.</li>
<li>Distribute your software however you want</li>
</ol>
<p>Learning the NSIS scripting language can be tricky, but you essentially have all you need with my example.  Hope this helps you out!</p>
<p>matlab_example_installer.nsi:</p>
<pre>!define VERSION "1.0"
!define BUILD "1"

InstallDir C:\YourCompany\app\matlab_installer_example
Name "Installer Example ${VERSION} BUILD ${BUILD}"
OutFile "Installer Example V${VERSION}_${BUILD}.exe"

Section "application"
  CreateDirectory $INSTDIR
  SetOutPath $INSTDIR
  File matlab_installer_example.exe
  File matlab_installer_example.ctf
  CreateDirectory "$SMPROGRAMS\YourCompany"
  CreateShortCut "$SMPROGRAMS\YourCompany\matlab_installer_example.lnk" \
                 "$INSTDIR\matlab_installer_example.exe"
SectionEnd

; To try out the installation on your own
;computer, just comment out this section.
Section "MATLAB runtime 7.7"
  SetOutPath $INSTDIR
  File MCRInstaller.exe
  ExecWait MCRInstaller.exe
  Delete $INSTDIR\MCRInstaller.exe
SectionEnd

Section -AdditionalIcons
  CreateShortCut "$SMPROGRAMS\YourCompany\Uninstall.lnk" \
                 "$INSTDIR\uninstall.exe"
SectionEnd

Section -Post
  WriteUninstaller "$INSTDIR\uninstall.exe"
SectionEnd

Function un.onUninstSuccess
  HideWindow
  MessageBox MB_ICONINFORMATION|MB_OK "$(^Name) was \
             successfully removed from your computer."
FunctionEnd

Function un.onInit
  MessageBox MB_ICONQUESTION|MB_YESNO|MB_DEFBUTTON2 \
            "Are you sure you want to completely remove \
            $(^Name) and all of its components?" IDYES +2
  Abort
FunctionEnd

Section Uninstall
  Delete "$INSTDIR\uninstall.exe"
  Delete "$INSTDIR\matlab_installer_example.exe"
  Delete "$INSTDIR\matlab_installer_example.ctf"

  Delete "$SMPROGRAMS\YourCompany\matlab_installer_example.lnk"
  Delete "$SMPROGRAMS\YourCompany\Uninstall.lnk"

  RMDir "$INSTDIR"
  RMDir "$SMPROGRAMS\YourCompany"
SectionEnd</pre>
]]></content:encoded>
			<wfw:commentRss>http://msbs.ca/matlab/?feed=rss2&amp;p=8</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Compiling MATLAB code and/or GUI&#8217;s</title>
		<link>http://msbs.ca/matlab/?p=7</link>
		<comments>http://msbs.ca/matlab/?p=7#comments</comments>
		<pubDate>Mon, 17 Dec 2007 20:37:14 +0000</pubDate>
		<dc:creator>Simon</dc:creator>
				<category><![CDATA[Beginner MATLAB]]></category>
		<category><![CDATA[MATLAB GUIDE programming]]></category>
		<category><![CDATA[compiler]]></category>
		<category><![CDATA[compiling]]></category>
		<category><![CDATA[encrypted]]></category>
		<category><![CDATA[GUI's]]></category>
		<category><![CDATA[GUIDE]]></category>
		<category><![CDATA[MATLAB]]></category>
		<category><![CDATA[mbuild]]></category>
		<category><![CDATA[mcc]]></category>

		<guid isPermaLink="false">http://msbs.ca/matlab/?p=7</guid>
		<description><![CDATA[MATLAB Compiler is an excellent solution for compiling MATLAB code or MATLAB graphical user interfaces (GUI&#8217;s).  The big advantages of compiling MATLAB code are:

 Writing math-based programming is really easy and quick in MATLAB
Building user interfaces to &#8220;wrap&#8221; your MATLAB code is very simple
Using MATLAB&#8217;s many different plots allows you display data in many [...]]]></description>
			<content:encoded><![CDATA[<p>MATLAB Compiler is an excellent solution for compiling MATLAB code or MATLAB graphical user interfaces (GUI&#8217;s).  The big advantages of compiling MATLAB code are:</p>
<ol>
<li> Writing math-based programming is really easy and quick in MATLAB</li>
<li>Building user interfaces to &#8220;wrap&#8221; your MATLAB code is very simple</li>
<li>Using MATLAB&#8217;s many different plots allows you display data in many ways</li>
<li>You can distribute your compiled applications freely without special licenses from MathWorks</li>
<li>Your m code is protected with 1024-bit RSA keys.</li>
</ol>
<p>The only significant consequence for compiling MATLAB code is that you have to include MATLAB&#8217;s huge ~165MB runtime (found here: &lt;MATLAB install directory&gt;\toolbox\compiler\deploy\win32\MCRInstaller X.X.exe).  Fortunately, you can install this just once on the target computer, and you can just update your compiled code as much as you want.</p>
<p>Here&#8217;s the compilation process for compiling a user interface built in MATLAB:</p>
<ol>
<li>  In MATLAB, type
<pre>mbuild -setup</pre>
</li>
<li>Choose your compiler (LCC is the default).  If you have another C++ compiler, use that.</li>
<li> To make an executable for your user interface (example_file.fig, example_file.m, and other m files), type
<pre>mcc -m example_file  % there are lots of options for mcc, type "doc mcc"</pre>
</li>
<li>Take the compiled files (example_file.exe, example_file.ctf, and the MCRInstallerX.X.exe) and put them on the target computer</li>
<li>When you run example_file.exe the first time, it will extract the example_file.ctf (which contains all the required files to run your application except all your files are encrypted so no one can read your code)</li>
</ol>
]]></content:encoded>
			<wfw:commentRss>http://msbs.ca/matlab/?feed=rss2&amp;p=7</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Adding user-defined settings to your MATLAB GUI</title>
		<link>http://msbs.ca/matlab/?p=3</link>
		<comments>http://msbs.ca/matlab/?p=3#comments</comments>
		<pubDate>Fri, 14 Dec 2007 23:00:48 +0000</pubDate>
		<dc:creator>Simon</dc:creator>
				<category><![CDATA[MATLAB GUIDE programming]]></category>
		<category><![CDATA[GUI]]></category>
		<category><![CDATA[GUIDE]]></category>
		<category><![CDATA[MATLAB]]></category>
		<category><![CDATA[settings]]></category>
		<category><![CDATA[XML]]></category>

		<guid isPermaLink="false">http://msbs.ca/matlab/?p=3</guid>
		<description><![CDATA[MATLAB&#8217;s GUIDE (Graphical User Interface Design Environment) allows for developing user interfaces with a MATLAB backend.  This allows you to create applications that interact with your M code.  A good starting place for building your own applications with MATLAB&#8217;s GUIDE is here.
For some applications, your users will have different settings, and you may [...]]]></description>
			<content:encoded><![CDATA[<p>MATLAB&#8217;s GUIDE (Graphical User Interface Design Environment) allows for developing user interfaces with a MATLAB backend.  This allows you to create applications that interact with your M code.  A good starting place for building your own applications with MATLAB&#8217;s GUIDE is <a href="http://www.mathworks.com/matlabcentral/fileexchange/loadFile.do?objectId=7598&amp;ref=rssfeed&amp;id=mostDownloadedFiles" title="Video: GUIDE Basics Tutorial " target="_blank">here</a>.</p>
<p>For some applications, your users will have different settings, and you may want your application to remember the settings from the last time the application was opened by storing settings in an XML file.</p>
<p>xml_settings.m essentially works like this:</p>
<ol>
<li>When the program is opened the first time, the default settings need to be written to the settings file -&gt; we need to create the file and write settings.</li>
<li>When the program is opened after the file has been written, don&#8217;t overwrite the settings, just get them -&gt; we need to open the file and read settings.</li>
<li>When the user has made a change to the settings, overwrite anything with the new setting -&gt; we need to write or overwrite settings.</li>
</ol>
<p>Here is <a href="http://msbs.ca/matlab/wp-content/uploads/2007/12/xml_settings_example.zip" title="the files and an example">the files and an example</a> (extract to your work folder).  Just type &#8220;saving_settings&#8221; in MATLAB.</p>
<p>xml_settings.m makes use of xml_write.m and xml_read.m by Jaroslaw Tuszynski found <a href="http://www.mathworks.com/matlabcentral/fileexchange/loadFile.do?objectId=12907&amp;objectType=FILE" title="xml_io_tools" target="_blank">here</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://msbs.ca/matlab/?feed=rss2&amp;p=3</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

