User Tools

Site Tools


matlab:introduction_to_matlab

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
matlab:introduction_to_matlab [2019/04/26 21:58] – [Matrix operations] mithatmatlab:introduction_to_matlab [2021/12/07 19:11] (current) – [Documenting functions] mithat
Line 6: Line 6:
  
 ===== What is it? ===== ===== What is it? =====
 +  * A //high-level//, //interpreted// language and environment targeting scientific computing.
   * A freaking huge, feature filled graphing calculator   * A freaking huge, feature filled graphing calculator
   * Comprehensive   * Comprehensive
Line 105: Line 106:
 <code matlab> <code matlab>
 % separate matrix rows with ';' % separate matrix rows with ';'
 +
 a = [1 2 3; 4 5 6; 7 8 9]; a = [1 2 3; 4 5 6; 7 8 9];
-= [9 8 7; 6 5 4; 3 2 1];+= [9 8 7; 6 5 4; 3 2 1];
 </code> </code>
  
 ===== Matrix operations ===== ===== Matrix operations =====
-Assume ''a'' and ''b'' are matrices and num is a scalar. 
  
 <code matlab> <code matlab>
-r = num * a;  % scalar multiplication+r = 1.25 * a; % scalar multiplication
 r = a * b;    % matrix multiplication r = a * b;    % matrix multiplication
 r = a .* b;   % elementwise multiplication r = a .* b;   % elementwise multiplication
Line 314: Line 315:
 ===== With "main" function ===== ===== With "main" function =====
   * Minimum syntax:   * Minimum syntax:
-<file matlab my_script.m> +<file matlab main.m> 
-function main+function main()
   area1 = traparea(1, 2, 3);   area1 = traparea(1, 2, 3);
   disp(area1);   disp(area1);
Line 342: Line 343:
 ===== Documenting functions ===== ===== Documenting functions =====
   * First comment block after first line is used to [[https://www.mathworks.com/help/matlab/matlab_prog/add-help-for-your-program.html|document functions]].   * First comment block after first line is used to [[https://www.mathworks.com/help/matlab/matlab_prog/add-help-for-your-program.html|document functions]].
-  * What user sees when she types ''help //function-name//''.+  * What user sees when they type ''help //function-name//''.
     * Only with single-function m-files.     * Only with single-function m-files.
 <file matlab traparea.m> <file matlab traparea.m>
matlab/introduction_to_matlab.1556315914.txt.gz · Last modified: 2019/04/26 21:58 by mithat

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki