title: Pls convert this R code of bit error probability into matlab
body: <p><a href="https://i.stack.imgur.com/e3mmr.jpg" rel="nofollow noreferrer">solution of the bit error probability problem</a></p>
  
  <pre><code>prob=function(E,m)        #--- prob is the estimated error probabity for given values of signal to 
                            #---noise ratio E and sample size m
  {
     stopifnot(E&gt;=0 &amp; m&gt;0)  #--- this says that the function won't accept negative values of E and 
                            #---m shoulde be at least 1
     n=rnorm(m)             #--- this says that n is a random sample of size m from N(0,1) 
                            #---distribution
     m=mean(n&lt; -sqrt(E))    #--- this says that m is the proportion of values in n which are less  
                            #---than the negative root of E
     return(m)              #--- this gives us the value of m, which is the estimated error          
                            #---probability
  }
  
  
  E=seq(0,2,by=0.001)
  sam=1000
  y=sapply(E,prob,m=sam)
  p=10*log10(E)
  
  plot(p, log(y),
       main="Graph For The Error Probabilities",
       xlab=expression(10*log[10](E)),
       ylab="log(Error Probability)",
       type="l")
  </code></pre>