title: How to call a function from a script in an other script matlab
body: <p><strong>Were given this scriptpoinfixe.m file that has this starting code :</strong></p>
  <pre><code>clear all; close all;
  
  g = @(x) -0.25* (x^3 - 3*x^2  - 2);
  x0=1.5;
  epsilon=1e-7; N=100;
  
  x(1)=x0;
  
  x1=g(x0);
  
  e_n=abs(x1-x0);
  errel=e_n/abs(x1);
  
  nbiterations=1;
  
  
  while (errel&gt;epsilon) &amp; (nbiterations &lt;N)
            x0=x1;
            x1=g(x0);
            e_n_1=e_n;
            e_n=abs(x1-x0);
            errel=e_n/abs(x1);
            nbiterations=nbiterations+1;
            x(nbiterations)=x1;
  end
  </code></pre>
  <p><strong>we've been asked to create the function pointfixe.m by modifying scriptpointfixe.m and deleting things in it.
  So right now i only tried to add the function like this :</strong></p>
  <pre><code>clear all; close all;
  
  
  g = @(x) -0.25* (x^3 - 3*x^2  - 2);
  x0=1.5;
  epsilon=1e-7; N=100;
  
  x(1)=x0;
  
  %%% 1ère itération de la methode de pt fixe
  x1=g(x0);
  
  e_n=abs(x1-x0);
  errel=e_n/abs(x1);
  % initialiation du compteur
  nbiterations=1;
  
  
  function [x] = pointfixe(g, x0, N, errel)
  
  while (errel&gt;epsilon) &amp; (nbiterations &lt;N)
            x0=x1;
            x1=g(x0);
            e_n_1=e_n;
            e_n=abs(x1-x0);
            errel=e_n/abs(x1);
            nbiterations=nbiterations+1;
            x(nbiterations)=x1;
  end
  end
  </code></pre>
  <p><strong>Now were asked to create a matlab script that we name devoir.m which defines the values of x0,g1, N and e
  so i created devoir.m :</strong></p>
  <pre><code>g = @(x) -0.25* (x^3 - 3*x^2  - 2);
  x0=1.5;
  epsilon=1e-7; N=100;
  
  
  pointfixe(g, x0, N, epsilon);
  </code></pre>
  <p><strong>But when i run devoir.m i get this error : Unrecognized function or variable 'pointfixe'.</strong></p>
  <p>This makes no sens for me since they are in the same folder, i don't understand why it's not found.
  Thanks for your help.</p>
  <p><a href="https://i.stack.imgur.com/7DHel.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/7DHel.png" alt="enter image description here" /></a></p>
  <p><strong>EDIT FOR COMMENT</strong></p>
  <p><a href="https://i.stack.imgur.com/koRRQ.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/koRRQ.png" alt="enter image description here" /></a></p>