Similar functions in R and Matlab

Although R and Matlab have many similarities, switching between the two languages is not always easy. Below is a lookup table that hopefully will make the process easier.

Matlab R Note
size dim
find which
( [
s(offset:(offset+len-1)) substr(s, offset, len)
@x lambda(x) function(x) { lambda(x) } Anonymous function in Matlab cannot contain more than one statements.
num2str as.character
ischar is.character
class class
unique unique
& (|) & (|) element-wise logic operators
~ !
sum sum vector function
length length vector function
dec2hex as.hexmode
strcat paste
Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: