title: "Array indices must be positive integers or logical values"
body: <p><a href="https://i.stack.imgur.com/PD1tW.png" rel="nofollow noreferrer">Problem Details and clues</a></p>
  <pre><code>%For this problem write a script file called NC.m that implements 
  %the Newton-Cotes method of integration for an arbitrary function f(x). It
  %should take as inputs the function and the limits of integration [a: b] and
  %output the value of the definite integral. Specifically, you should use the
  %Trapezoid rule as presented in Equation (11.73)
  function [f]= NC(a,b,fun) %newton-cotes 
  %a and b are limits of intergration 
  %setting it up 
  f(a)= fun(a); %y value for lower limit 
  f(b)= fun(b); %y value for upper limit 
  %the actual function 
  f= (b-a)*(f(a)+f(b))/2; 
  end 
   
  </code></pre>
  <p>What am i doing wrong? When I type, [f]= NC(-3,0,fun) and set fun=  @(x)normpdf(x) . it keeps on returning &quot;Array indices must be positive integers or logical values&quot;. Can someone shine some light on this?</p>