<p>I'm a new user of Matlab, can you please help:<br>
I have the following code in an .M file:</p>

<pre><code>function f = divrat(w, C)
S=sqrt(diag(diag(C)));
s=diag(S);
f=sqrt(w'*C*w)/(w'*s);
</code></pre>

<p>I have stored this file (divrat.M) in the normal Matlab path, and therefore I'm assuming that Matlab will read the function when it's starting and that this function therefore should be available to use.</p>

<p>However, when I type</p>

<pre><code>&gt;&gt; divrat(w, C)
</code></pre>

<p>I get the following error</p>

<blockquote>
  <p>??? Undefined function or method 'divrat' for input arguments of type 'double'.  </p>
</blockquote>

<p>What is the error message telling me to do, I can't see any error in the code or the function call?</p>

The error code indicates the function definition cannot be found. Make sure you're calling the function from the same workspace as the
```
divrat.m
```
file is stored. And make sure
```
divrat
```
function is not a subfunction, it should be first function declaration in the file. You can also try to call the function from the same
```
divrat.m
```
file in order to see if the problem is with workspace selection or the function.
By the way, why didn't you simply say
```
```
s = sqrt(diag(C));
```
```
Wouldn't it be the same?