Wiki - README‎ > ‎Math‎ > ‎

Matlab / Octave

array manipulation tips and tricks [link]

LLE Matlab Implementation (link)

Octave documentation (link)

non-classical multidimensional scaling (link)
classical multidimensional scaling (link)

matlab programming (link)

loading c# data in matlab (link)
CSMatIO (link)

from ~/software/matlab/toolbox/matlab/demos/html/GettingStartedwithMATLAB.html
>> a=1
>> t=[1 2 3 4 5]
>> t=1:5                 % auto-gen array from 1 to 5 be step 1
>> t=0:0.1:1             % auto-gen array from 0.0 to 1.0 by step 0.1
>> whos                  % list variables
>> y=sin(t*pi)
>> plot(t,y)
>> x=3+4i                % imaginary
>> a=[1 2 3;4 5 6;7 8 9] % 2dim matrix
>> data=rand(5,5)
>> size(data)            % returns size of matrix
>> b=a'                  % transpose
>> c=a*b                 % matrix mult
>> c=a.*b                % element wise multiplication
>> inv(a)                % inverse of a
>> a(2,3)                % indexing, row 2 col 3
>> data(1:3,2:end)
>> data(1:2,:)=0         % set rows 1 and 2 (all cols) to 0
>> surf(w)               % create surface plot of matrix w

from (link)
% inline functions
>> f = inline('sqrt(x.^2 + y.^2)','x','y');
>> f(3,4)
ans =
     5

% evaluating functions by name
>> feval( 'functionname', a, b, c )

if expr1
elseif expr2
else
end

switch expr (scalar or string)
case value1
case value2
otherwise
end

x = ceil(10*rand)
switch x
  case {1,2}
    disp('prob 20%')
  case {3,4,5}
    disp('prob 30%')
  otherwise
    disp('prob 50%')
end

for var = range
end

relations: ==, <, <=, >, >= ~=
logical: |, &, ~

>> a = [1 1 3 4 1];
>> ind = (a == 1)
ind =
     1 1 0 0 1
>> ind = find(a == 1)
ind =
     1 2 5
>> b = a(ind)
b =
   1 1 1

isempty(var) % returns 1 if var is empty array

char(strvar), double(strvar), strcmp(str1,str2),strcat(str1,str2)
int2str(var), num2str(var)
floor(),ceil(),fix(),round()  % rounds towards -inf, +inf, 0, nearest int
aoeu
Comments