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