title: How to calculate p-value for t-test in MATLAB?
body: <p>Is there some simple way of calculating of p-value of t-Test in MATLAB. </p>
  
  <p>I found something like it however I think that it does not return correct values:   </p>
  
  <p><code>Pval=2*(1-tcdf(abs(t),n-2))</code></p>
  
  <p>I want to calculate the p-value for the test that the slope of regression is equal to 0. Therefore I calculate the Standard Error   </p>
  
  <p>$SE= \sqrt{\frac{\sum_{s = i-w }^{i+w}{(y_{s}-\widehat{y}<em>s})^2}{(w-2)\sum</em>{s=i-w}^{i+w}{(x_{s}-\bar{x}})^2}}$ </p>
  
  <p>where $y_s$ is the value of analyzed parameter in time period $s$,<br>
   $\widehat{y}_s$ is the estimated value of the analyzed parameter in time period $s$,<br>
  $x_i$ is the time point of the observed value of the analysed parameter,<br>
  $\bar{x}$ is the mean of time points from analysed period and then<br>
  $t_{score} = (a - a_{0})/SE$ where $a_{0}$ where $a_{0} = 0$.</p>