The weakly_nonlinear function includes these lines:
h=@eta;
while (sol_error>converge_limit)
F=-feval(h,x,sol,p,F,h,B,choice)';
This calls the eta function with @eta as the fifth input argument. Let's look at a chunk of eta:
function y=eta(x,f,p,F,h,B,choice)
N=length(x);
y=zeros(1,N+1);
rho=1;
g=9.81;
a_1=1-f(N+1);
a_2=0.75./h;
The last line is the one throwing the error. When computing a_2 you're dividing by @eta. That doesn't look right. Usually in this type of problem a variable named h represents the spacing between elements in x or something similar. If that's the case, you probably want to use diff(x) or something along those lines.
Best Answer