How to convert R code to MATLAB?

2 views (last 30 days)
noramalina mohd hatta
noramalina mohd hatta on 18 Mar 2016
Edited: Stephen23 on 18 Mar 2016
HI. Anyone can help me with this R code? I need to convert in MATLAB code.
S2N <- function(A, C) { # computes robust signal to noise ratio for one gene
x <- split(A, C)
m1 <- mean(x[[1]])
m2 <- mean(x[[2]])
s1 <- ifelse(length(x[[1]]) > 1, sd(x[[1]]), 0)
s2 <- ifelse(length(x[[2]]) > 1, sd(x[[2]]), 0)
s1 <- ifelse(s1 < 0.1*abs(m1), 0.1*abs(m1), s1) # use 10% of the mean if the sd is zero or too low
s2 <- ifelse(s2 < 0.1*abs(m2), 0.1*abs(m2), s2)
s2n <- (m1 - m2)/(s1 + s2 + 0.1)
return(s2n)
}

Answers (0)

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!