I saw the other two posts on this community about this issue, and they are both dimensional issues. However, I believe I do not have a dimensional issue here in my problem but still get the same error message. I tried 'fsolve' and symbolic equation 'solve', none of them worked (for the former, I got the initial value as the solution, while for the latter, I got another error). I paste my whole codes here just for reference, but the issue comes from the last 3 lines. I would very much appreciate your help!
%% Exogenous parameters
gamma = 0.181;zeta = 10.63;nu = 4/3;chi = 0.233;pi_r = 0.55;pi_n = 1 - pi_r;A = 1;alpha = 0.53;a=alpha;phi_0 = 0.4226;tau = 0;g = 0.0083;phi_1 = phi_0;%% Objective function
obj = @(x) -1*(pi_r*(log(x(1)) - zeta*x(2)^(1 + nu) / (1 + nu) + chi*log(x(5))) + ... pi_n*(log(x(3)) - zeta*x(4)^(1 + nu) / (1 + nu) + chi*log(x(5))));nonlcon = @nonlinear_cons;A = [];b = [];Aeq = [];beq = [];lb = [];ub = [];x0 = [0.13, 0.38, 0.185, 0.41, 0.1];[x,fval,exitflag,output,lambda,grad,hessian] = fmincon(obj,x0,A,b,Aeq,beq,lb,ub,nonlcon);lr = x(2);ln = x(4);mu = lambda.ineqnonlin;func = @(p) p./ (1+p) - a./(1-a) .* ... pi_r.*phi_1.*lr ./ (pi_n.*(a.*A.^(1 ./ a).*(1 - a)^((1-a) ./ a) ./ ... (((1+p).*phi_1).^((1-a)./a))).*ln) .* (1/mu .* (zeta .* lr.^nu ./ phi_1) - 1);p0 = 0.1;solx = fzero(func,p0)
<stopping criteria details>Operands to the || and && operators must be convertible to logical scalar values.Error in fzero (line 327) elseif ~isfinite(fx) || ~isreal(fx)Error in simpleTax (line 55)solx = fzero(func,p0)
Best Answer