Wednesday, 11 June 2014

画Beta分布图
X=0:0.01:1;

y1 = betapdf(X, 40, 40 );
figure;
plot(X,y1,'Color','g');

hold on;
y2 = betapdf(X,100,100);
plot(X,y2,'Color','r');

hold on;
y3 = betapdf(X,20,40);
plot(X,y3,'Color','b');

Friday, 6 June 2014

intersect 例子

INTERSECT(A,B) for vectors A and B, returns the values common to the two vectors. MATLAB sorts the results.  A and B can be cell arrays of strings.

For example, A=[1 2 3], B= [ 2 3 4]
The result of intersect(A,B) should be [2 3]

[dummy, indexA, indexB] = intersect(A,B)

dummy = [2 3]
indexA = [1 2]
indexB = [2 3]

Tuesday, 27 May 2014

CUMPROD (Cumulative product of elements) 例子

Example:

if X=[0 1 2;3 4 5]
then cumprod(X,1) is
[0 1 2; 0 4 10]
沿着列的方向累积连乘 (对第一个长度不为1的维度进行计算)
所以第一行,保持不变,第二行的元素变成他本身与对应的第一行元素的乘积
cumprod(X,2) 沿着行方向
所以结果为[0 0 0;3 12 60]