matlab:introduction_to_matlab
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revisionNext revisionBoth sides next revision | ||
matlab:introduction_to_matlab [2019/04/26 21:48] – [Variables] mithat | matlab:introduction_to_matlab [2019/04/26 22:00] – [Matrix operations] mithat | ||
---|---|---|---|
Line 47: | Line 47: | ||
===== Comments ===== | ===== Comments ===== | ||
- | * Use a percent sign. | + | * Use the percent sign. |
<code matlab> | <code matlab> | ||
- | % like this | + | % a single line comment |
a = 99; % this works too | a = 99; % this works too | ||
%{ | %{ | ||
- | foo = 'This is a'; | + | foo = 'multiple line comments'; |
- | baz = 'multiple line comment'; | + | baz = 'use curly brackets inside'; |
+ | qux = 'a pair of percent signs.'; | ||
%} | %} | ||
</ | </ | ||
Line 104: | Line 105: | ||
<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]; | ||
- | c = [9 8 7; 6 5 4; 3 2 1]; | + | b = [9 8 7; 6 5 4; 3 2 1]; |
</ | </ | ||
Line 111: | Line 113: | ||
<code matlab> | <code matlab> | ||
- | % matrix | + | r = 1.25 * a; % scalar |
- | r = a * b; | + | r = a * b; % matrix |
- | + | r = a .* b; | |
- | % elementwise | + | r = a ./ b; % elementwise division |
- | r = a .* b; | + | |
- | + | ||
- | % elementwise | + | |
- | r = a ./ b; | + | |
</ | </ | ||
matlab/introduction_to_matlab.txt · Last modified: 2021/12/07 19:11 by mithat