Matlab: Programming Environment


Published on

Matlab: Programming Environment

Published in: Technology
  • Be the first to comment

  • Be the first to like this

No Downloads
Total views
On SlideShare
From Embeds
Number of Embeds
Embeds 0
No embeds

No notes for slide

Matlab: Programming Environment

  1. 1. Matlab: Programming Environment<br />
  2. 2. Your first run<br />Section 1: The toolbar is where you can access the various features, tools and options regarding your code, debugging process, formatting, etc<br />
  3. 3. Your first run<br />Section 2: The file-manager shows your current directory and the files in it. You can change the directory by double clicking any folder or using the drop-down menu at the top.<br />
  4. 4. Your first run<br />Section 3: The command window is the place from where you tell MATLAB what is to be done! You have the option of either writing commands directly or running a &apos;MATLAB&apos; file (with the extension .m) which would consist of commands, functions or programs. <br />
  5. 5. Your first run<br />Section 4: When you write a new program or type in some commands, you would almost always, use variables to store the values obtained. The workspace shows you all your current variables and their values and allows you to edit, copy or duplicate them. <br />
  6. 6. Your first run<br />Section 5: The command history window saves your recent commands and helps you in keeping a track of what you have been up to! <br />It comes out quite handy when you have to use long commands repeatedly: Simply double click on that command in the command history window and it will start running! <br />
  7. 7. MATLAB Help<br />MATLAB provides an excellent documentation of all its toolboxes and their respective commands. It also includes sample codes and examples! Go to the Help option and MATLAB and click on &apos;Product Help&apos;(or simply press F1). <br />
  8. 8. MATLAB Help<br />Explore the Help contents and you would find loads of useful things. Here is a snapshot of the first example in Image Processing toolbox. It teaches how to read and display an image. <br />
  9. 9. Function Browser: a quick search tool!<br />Click on &apos;Help&apos; on the toolbar and go to &apos;Function Browser&apos; (or press Shift+F1). This is what will pop up:<br />
  10. 10. Function Browser: a quick search tool!<br />The &apos;Function Browser&apos;, as the name suggests, is a quick search tool for description and synopsis of commands and functions of MATLAB. In the figure towards the right, I have searched for &apos;contrast&apos; and it lists all the functions and commands related to that keyword. It gives concise information about the function you are looking for. <br />
  11. 11. Basic Functions<br />Matlab allows us to define (and evaluate) our own functions as well. For example, lets define a function f(x)=x2+1. To do this, we simply type in f=x.^2+1. Since x has a value of 10, the answer is 101. We can now change the value of x. For example, type x=5 and enter, then type f=x.^2+1 again. We should now get 26. <br />
  12. 12. Basic Functions<br />Almost all of Matlab&apos;s basic commands revolve around the use of vectors. A vector is defined by placing a sequence of numbers within square braces:<br />&gt;&gt; v = [3 1] <br />v = 3 1 <br />
  13. 13. Basic Functions<br />To view the vector just type its label:<br />&gt;&gt; v <br /> v = 3 1 <br />&gt;&gt; v = [3 1 7 -21 5 6]<br /> v = 3 1 7 -21 5 6<br />
  14. 14. Basic Functions<br />To define a matrix, we can treat it like a column of row vectors (note that the spaces are required!):<br />&gt;&gt; A = [ 1 2 3; 3 4 5; 6 7 8] <br />A = 1 2 3 <br /> 3 4 5 <br /> 6 7 8 <br />
  15. 15. Basic Functions<br /> the whoscommand will let you know all of the variables you have in your work space.<br />&gt;&gt; whos<br /> Name Size Bytes Class<br /> A 3x3 72 double array <br />B 3x3 72 double array<br /> v 1x5 40 double array <br />Grand total is 23 elements using 184 bytes<br />
  16. 16. Basic Functions<br /> Sometimes you would like to clear all of your data and start over. You do this with the &quot;clear&quot; command. <br />&gt;&gt; clear<br /> &gt;&gt; whos<br />
  17. 17. Visit more self help tutorials<br />Pick a tutorial of your choice and browse through it at your own pace.<br />The tutorials section is free, self-guiding and will not involve any additional support.<br />Visit us at<br />