MATLAB: Error using fzero ” FUN must be a function, a valid string expression, or an inline function object”

fsolvefzeroMATLABplot

I am getting errors while using fsolve or fzero in the following code:
U = 1;
while U < 20
eq = @(q) 2.*(1-cos(2.*pi.*q));
hq = @(q,n0) ((eq(q)).^2+2.*U.*n0.*(eq(q))).^0.5;
y = @(q,n0) (((eq(q))+(U.*n0))./hq(q,n0))-1;
a = -0.5;
c = -0.01;
v = @(n0) (integral(@(q) y(q,n0),a,c));
cv =@(n0) n0+(0.5*v(n0))-1;
n0 = fzero(cv(n0),0.1);
plot(U,n0)
hold on
U = U + 1;
end
Can anyone please help me out?

Best Answer

n0 = fzero(cv,0.1);
Related Question