Hello everyone,
I have a big code that pin down to a system of nonlinear equations which I want to solve using fsolve. I am facing an error message: "Dot indexing is not supported for variables of this type". A simplified version of the code is:
function out = equilibrium_F(par_n,tax_n,tar_n,init_n,... par_m,tax_m,tar_m,init_m,... par_z,tax_z,tar_z,init_z)cons_n = @(Q) pd_cons(I(Q(115:129) , Q(160:174) , Q(205:207) , Q(214:217) ,... Q(13) , Q(14) , Q(15) , Q(16) , Q(17) , Q(18) ,... Q(10) , Q(1) , init_n) ,... Q(7) , ... Q(19:33) , Q(34:48) , Q(49:63) ,... Q(64) , ... par_n , tax_n , tar_n ,... par_m , tax_m , tar_m ,... par_z , tax_z , tar_z); XA_i_n = @(Q) cons_n.XA_i(Q); INV_i_n = @(Q) cons_n.INV_i(Q);XMT_i_nm = @(Q) cons_n.XMT_i_nm(Q);XMT_i_nz = @(Q) cons_n.XMT_i_nz(Q);Tax_rev_cons_n = @(Q) cons_n.Tax_rev_cons(Q);F1 = @(Q) (XA_i_n(Q),INV_i_n(Q), ...)F2 = @(Q) (XMT_i_nm(Q), XMT_i_nz(Q), ...)..F42F =@(Q) [F1(Q);F2(Q);F3(Q);F4(Q);F5(Q);F6(Q);F7(Q);F8(Q);F9(Q);F10(Q);... F11(Q);F12(Q);F13(Q);F14(Q);F15(Q);F16(Q);F17(Q);F18(Q);F19(Q);F20(Q);... F21(Q);F22(Q);F23(Q);F24(Q);F25(Q);F26(Q);F27(Q);F28(Q);F29(Q);F30(Q);... F31(Q);F32(Q);F33(Q);F34(Q);F35(Q);F36(Q);F37(Q);F38(Q);F39(Q);F40(Q);... F41(Q);F42(Q)];options = optimoptions('fsolve','Algorithm','trust-region'); x0 = ones(1,225); x0(1,1:3) = 0; x0(1,7:9) = 0; [out,fval,exitflag,output] = fsolve(F,x0,options); end
I get this error message:
Dot indexing is not supported for variables of this type.
Error in equilibrium_F>@(Q)cons_n.Tax_rev_cons(Q) (line 129)
Tax_rev_cons_n = @(Q) cons_n.Tax_rev_cons(Q);
I have have two questions with regard to this:
- How can I solve the issue of using an indexed function output as a function of original inputs.
- Using fsolve needs initial values but the number of variables and the system complexity is very high to be able to provides these. Is there a way to get these somehow generically? or is there another way to sovle such large system of nonlinear equations other than fsolve?
Many thanks in advance for your help.
Best Answer