User Tools

Site Tools


matlab:matlab_examples

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
Last revisionBoth sides next revision
matlab:matlab_examples [2016/05/01 03:52] – [m-file with main function] mithatmatlab:matlab_examples [2016/05/04 01:56] – [m-files with main function] mithat
Line 1: Line 1:
-[[http://example.com|External Link]]====== MATLAB m-file Examples ======+====== MATLAB m-file Examples ======
  
 ===== Simple script ===== ===== Simple script =====
Line 16: Line 16:
  
 ===== Function m-file ===== ===== Function m-file =====
 +Ref.((Recktenwald, Gerald. "MATLAB Functions -- Basic Features." MATLAB Functions -- Basic Features. Accessed April 30, 2016. http://web.cecs.pdx.edu/~gerry/MATLAB/programming/basics.html.))
 <file matlab traparea.m> <file matlab traparea.m>
 function area = traparea(a, b, h) function area = traparea(a, b, h)
Line 30: Line 30:
  
 ===== m-files with "main" function ===== ===== m-files with "main" function =====
 +Ref.((Recktenwald, Gerald. "MATLAB Functions -- Basic Features." MATLAB Functions -- Basic Features. Accessed April 30, 2016. http://web.cecs.pdx.edu/~gerry/MATLAB/programming/basics.html.))
 <file matlab compute_trapezoid.m> <file matlab compute_trapezoid.m>
 function main function main
Line 48: Line 48:
 </file> </file>
  
 +Ref.((Unknown))
 <file matlab quads.m> <file matlab quads.m>
 function main() function main()
Line 61: Line 62:
  
 d = disc(a, b, c); d = disc(a, b, c);
-x1 = (-b + d) / (2*a); +x1 = (-b + sqrt(d)) / (2*a); 
-x2 = (-b - d) / (2*a);+x2 = (-b - sqrt(d)) / (2*a);
 end end
  
Line 68: Line 69:
 % dis = disc(a,b,c) % dis = disc(a,b,c)
 % Return the discriminant of a, b, c. % Return the discriminant of a, b, c.
-dis = sqrt(b^2 - 4*a*c);+dis = b^2 - 4*a*c;
 end end
 </file> </file>
 +
 ===== Returning multiple values ===== ===== Returning multiple values =====
 +Ref.((Recktenwald, Gerald. "MATLAB Functions -- Basic Features." MATLAB Functions -- Basic Features. Accessed April 30, 2016. http://web.cecs.pdx.edu/~gerry/MATLAB/programming/basics.html.))
 <file matlab c_to_p.m> <file matlab c_to_p.m>
 function main function main
matlab/matlab_examples.txt · Last modified: 2021/12/07 19:41 by mithat

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki