Basic Matlab Function Equivalents:
Matlab | R | Description |
ones(n,m)*a | mat.or.vec(n,m)*a | initialize matrix with values |
rand(m) | runif(n,min,max) | n float random numbers between min&max. |
sample(min:max,n) | picks n elements of the data given as first argument (i.e. integers!) | |
reshape(a,[n,m..]) | matrix(a,nrow=n,ncol=m) | reshape data structure into a matrix |
for i=1:30 op(i); end | for (i in 1:30); { op(i); } | for loop! |
function [x y z] = uvw(a,b,c=3) op(a,b,c); end | uvw<-function(a,b,c=3) { op(a,b,c); } | function definition |
a = []; | a <- matrix(nrows=0,ncols=3) | how to init a matrix to be grown dynamically |
a = [b;c;d]; | a <- rbind(b,c) | concatenate matrix vertically |
a = [b,c,d]; | a <- cbind(b,c,d) | concatenate matrix horizontally |
.. | .. | .. |
Keine Kommentare:
Kommentar veröffentlichen