Http://www.cnblogs.com/wentingtu/archive/2012/03/30/2425582.htmlR function more Complete blog
Seeking redundancy
y = 5; x = 2; y%%x = 1;
MATLAB mod (y,x);
R y%%x;
Number of rows to fetch
Matlab size (m,1);
R Nrow (m);
Repeating matrix
1 2 3->1 2 3 1 2 3
Matlab Repmat (m,i,j) repeats I times by row, repeating J times by column. Use Repmat (m,1,2) as above
If you want to reach 1 2 3
1 2 3 effect with Repmat (m,2,1)
R Rep (m,2) repeats by column
Merging matrices
M1= 1 2 3 m2=4 5 6 m=1 2 3 4 5 6
Horizontal Merge
R Cbind (M1,M2);
matlab [M1,M2];
Merge vertically
R Rbind (M1, M2)
MATLAB [M1 m2];
No back-up random sampling
m, for the whole. Num is the number of samples to extract
Matlab randsample (m,num); Returns a k-by-1 vector y of values sampled uniformly at random, without replacement, from the Integers 1 to n.
R sample (M,num,replace=false); False means not to put back the sample, true to put back the sample
Creating a special matrix
R Mat.or.vec (i, J) I row J column all 0 matrices
MATLAB Zeros (I,J)
SSE = Matrix (data, I, J,byrow = TRUE) I row J column, where the data is data, arranged by rows
Find vector length
v = 1 2 3
R Length (v) =3
Matlab Length (v) =3
Multiply matrix corresponding elements
M1=1 2 3 m2= 4 5 6 m = 4 10 18
Matlab m1.*m2;
R m1*m2;
Normal multiplication of matrices
Matlab m1*m2
R m1%*%m2
Find standard deviation of sample
R SD (v)
MATLAB STD (v)
Find the lowest value subscript (usually take a vector, and then ask)
x = 5 2 1 4 10
R which.min (x) = 3
MATLAB find (x = = min (x))
Find the subscript where the specified element is located and reject
index= find (Matrix = = num) index holds the subscript for NUM, subscript is computed by column, and the second column is counted after one column
index = (vector > num) is larger than Num's subscript takes 1, the other takes 0, which is generally picked out and then used for culling
Vector (index) = []; exclude the element where index is located
Remove vector Specifies the value of the underlying
x = 5 8 10 11 12
R X[-1] = 8 10 11 12
Matlab x (1) =[]
Take the nearest number from 0
x = 1.7 y=-1.7
R As.integer (x) 1 As.integer (y) =-1
fix for MATLAB (x) fix (y)
Comparison of small function and r in MATLAB