problem using quad function

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

problem using quad function

trinka
Hello,

I am an unexpert Octave user, so sorry if my post may look naive.

I am trying to integrate a quite complex function but I will give you a simplified example:



 
Where H is the Heaviside step function.
I have prepared this script:
….
function y = heaviside  (x)
  y =ceil(sign(x)/2);
 endfunction

L=2;
V(1)=10;
V(2)=20;
….
qtot=0.
for j=1:nlayer,
  function y = fun (x)
   y =heaviside(x-V(j));
 endfunction
 q=quad("fun",0,L)
qtot=q+qtot;
end

but I get the following error message “’V’ undefined near line 20’.

Do you have any hint?