<h2>7.1: Application structure <a href="User_guide7.html"><img src="Images/uparrow.png" border="0" align="top" alt="Go back up one level"/></a></h2>
<p>There are many ways to build graphical applications in MATLAB, but
here we will take a very simple approach. If the application were to become
larger and more complex, this approach would be changed to better mitigate
the complexity. Some notes on this are contained <a href="demoBrowserScalability.html">at the end</a>.</p>
<p>The application is structured as a single function with callbacks and other helper
functions stored as "nested" subfunctions, i.e. functions inside the main function. This has
the advantage that the nested subfunctions can share access to any variables
declared in the main function. This is also a risk as anything we accidentally
declare in the main function becomes "global" within the application. For that reason
<em>all</em> logic is put into subfunctions and we restrict the main
function to just declaring two shared variables:</p>
<ul>
<li><b>data</b>: a structure containing all shared data</li>
<li><b>gui</b>: a structure containing handles to GUI widgets</li>