2018/09/03

Matlab: feval() - Call functions with the function name as a string input

To call any Matlab function, use feval() with the function nameas the first input string and the parameters of the function as the other remaining input arguments.

For example, for sayHello.m:

function sayHello(name)

fprintf('Hello %s!\n',name);

Results of the command line with fevel():

>> sayHello('Matlab')
Hello Matlab!
>> feval('sayHello','World')
Hello World!

Reference:

feval() - Evaluation function (MathWorks)

2018/08/21

Mathematics for Machine Learning 機器學習的數學

Siraj Raval的影片介紹,機器學習主要有以下幾種的數學:

Calculus 微積分 - 最佳化

Linear Algebra 線性代數 - 實現演算法

Probability 機率 - 預估結果

Statistics 統計 - 找出目標

----

參考資料

Mathematics of Machine Learning (Siraj Raval)
Logistic regression (Wikipedia) 邏輯迴歸 (維基百科)

2018/08/09

Matlab: Find local maxima 求局部極大值

To find the local maximum values in Matlab, use findpeaks():

>> a = [7 -2 -5 8 -6 -3 4 9 6 3 -2 5 8 11 7 3 -5];
[peaks, items] = findpeaks(a);
>> peaks

peaks =

     8     9    11

>> items

items =

     4     8    14

>> 

To find N large elements of a vector in Matlab in descending order, use maxK():

K>> [peaks, items] = maxk(a,5);
K>> peaks

peaks =

    11     9     8     8     7

K>> items

items =

    14     8     4    13     1

K>> 

Reference:

findpeaks - Find local maxima (MathWorks)

2018/08/07

Matlab: Flip vector 水平翻轉向量

>> a = [1 2 3 4 5 6];
>> flip(a)

ans =

     6     5     4     3     2     1

2018/07/30

Matlab: Maximum element and index

To the the maximum value of an array and the index of the maximum value, use the max() function  as below:

>> a = [1 4 5 7 3 2]

a =

     1     4     5     7     3     2

>> [max, index] = max(a)

max =

     7


index =

     4

>> 

Reference:

max - Maximum elements of an array (MathWorks)

2018/06/28

Vector Spaces 向量空間

2D Vector Space
vector v = (x, y) or (v1, v2)

3D Vector Space
vector v = (x, y, z) or (v1, v2, v3)

N-Dimensional Vector Space
vector v = (v1, v2, v3, ..., vN)

References

Vector Space (Wikipedia)
What is a Vector Space? (Video)