matlab:matlab_examples
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
matlab:matlab_examples [2016/05/01 03:52] – [m-file with main function] mithat | matlab:matlab_examples [2021/12/07 19:41] (current) – [m-files with "main" function] mithat | ||
---|---|---|---|
Line 1: | Line 1: | ||
- | [[http:// | + | ====== MATLAB m-file Examples ====== |
===== Simple script ===== | ===== Simple script ===== | ||
Line 16: | Line 16: | ||
===== Function m-file ===== | ===== Function m-file ===== | ||
+ | Ref.((Recktenwald, | ||
<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 " | ===== m-files with " | ||
+ | Ref.((Recktenwald, | ||
+ | |||
+ | Note: On some platforms you may receive a warning if the name of the file (without extension) doesn' | ||
<file matlab compute_trapezoid.m> | <file matlab compute_trapezoid.m> | ||
- | function main | + | function main() |
area1 = traparea(1, | area1 = traparea(1, | ||
disp(area1) | disp(area1) | ||
Line 48: | Line 51: | ||
</ | </ | ||
+ | Ref.((Unknown)) | ||
<file matlab quads.m> | <file matlab quads.m> | ||
function main() | function main() | ||
Line 61: | Line 65: | ||
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 72: | ||
% 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 | ||
</ | </ | ||
+ | |||
===== Returning multiple values ===== | ===== Returning multiple values ===== | ||
+ | Ref.((Recktenwald, | ||
<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