forked from freesurfer/freesurfer
-
Notifications
You must be signed in to change notification settings - Fork 2
MatLab
Willy Mills edited this page Nov 4, 2017
·
1 revision
Operation | Syntax | Note |
row vector | [1 2 3 4] or [1, 2, 3, 4] | |
2d matrix | [1 2 3; 4 5 6; 7 8 9] | |
transpose | a' (single quote) | |
inverse | inv(a) | |
matrix multiply | a * b | |
element-wise multiply | a .* b | |
element-wise power | a.^3 | |
complex number | 3 + 4i or 3 + 4j | |
indexing | a(row, column) | one based |
inclusive index | a(start:end) | inclusive |
generative | start:step:end | inclusive |
generative | start:end | step=1 |
all | a(3,:) | all of third row |
spread results | [maxA, location] = max(A0 ] | |
comment | a = 7 % comment is here |
indexed loop | for k=1:5 ... end |
conditional | if..elseif..else..end |
Method | Action |
whos | list workspace variables |
function result = myFunc(args) result = 3 * arg end
function [x, y] = myFunc(args) x = 3 * arg y = 5 * arg end
sqr @(x) x.^0.5;