Hello all,
Can you please tell me how can I solve 4 equations with 2 unknowns in MATLAB?
equationsno apparent urgencyurgent
function eqs = funs(S)S11 = S(1);S22 = S(2);S33 = S(3);S12 = S(4);S13 = S(5);S23 = S(6);A11= 0.2346 + 0.1345i;A21= 0.8550 - 0.4363i;A22= -0.0412 + 0.2931i;B11= 0.2346 + 0.1345i;B21= 0.8550 - 0.4363i;B22= -0.0412 + 0.2931i;D11= 0.2346 + 0.1345i;D21= 0.8550 - 0.4363i;D22= -0.0412 + 0.2931i;c11= 0.169033453278504 + 0.127942837737115i;c22= 0.169951074114244 + 0.148423165394202i;c33= 0.168939745364374 + 0.142538799523638i;c21= -0.00172796568379862 + 0.201091742020021i;c31= -0.00152297772077853 + 0.199585730377658i;c32= -0.00523160858486265 + 0.199472640309087i;eqs = [(A11.*A22.*S11 - A21.^2.*S11 - A11 + A11.*B22.*S22 + A11.*D22.*S33 - A21.^2.*B22.*S12.^2 - A21.^2.*D22.*S13.^2 + A11.*A22.*B22.*S12.^2 + A11.*A22.*D22.*S13.^2 + A11.*B22.*D22.*S23.^2 + A21.^2.*B22.*S11.*S22 + A21.^2.*D22.*S11.*S33 + A21.^2.*B22.*D22.*S11.*S23.^2 + A21.^2.*B22.*D22.*S13.^2.*S22 + A21.^2.*B22.*D22.*S12.^2.*S33 - A11.*A22.*B22.*S11.*S22 - A11.*A22.*D22.*S11.*S33 - A11.*B22.*D22.*S22.*S33 - A11.*A22.*B22.*D22.*S11.*S23.^2 - A11.*A22.*B22.*D22.*S13.^2.*S22 - A11.*A22.*B22.*D22.*S12.^2.*S33 - 2.*A21.^2.*B22.*D22.*S12.*S13.*S23 - A21.^2.*B22.*D22.*S11.*S22.*S33 + 2.*A11.*A22.*B22.*D22.*S12.*S13.*S23 + A11.*A22.*B22.*D22.*S11.*S22.*S33)./(A22.*S11 + B22.*S22 + D22.*S33 + A22.*B22.*S12.^2 + A22.*D22.*S13.^2 + B22.*D22.*S23.^2 - A22.*B22.*S11.*S22 - A22.*D22.*S11.*S33 - B22.*D22.*S22.*S33 - A22.*B22.*D22.*S11.*S23.^2 - A22.*B22.*D22.*S13.^2.*S22 - A22.*B22.*D22.*S12.^2.*S33 + 2.*A22.*B22.*D22.*S12.*S13.*S23 + A22.*B22.*D22.*S11.*S22.*S33 - 1)-c11; -(A21.*B21.*(S12 + D22.*S13.*S23 - D22.*S12.*S33))./(A22.*S11 + B22.*S22 + D22.*S33 + A22.*B22.*S12.^2 + A22.*D22.*S13.^2 + B22.*D22.*S23.^2 - A22.*B22.*S11.*S22 - A22.*D22.*S11.*S33 - B22.*D22.*S22.*S33 - A22.*B22.*D22.*S11.*S23.^2 - A22.*B22.*D22.*S13.^2.*S22 - A22.*B22.*D22.*S12.^2.*S33 + 2.*A22.*B22.*D22.*S12.*S13.*S23 + A22.*B22.*D22.*S11.*S22.*S33 - 1)-c21; -(A21.*D21.*(S13 + B22.*S12.*S23 - B22.*S13.*S22))./(A22.*S11 + B22.*S22 + D22.*S33 + A22.*B22.*S12.^2 + A22.*D22.*S13.^2 + B22.*D22.*S23.^2 - A22.*B22.*S11.*S22 - A22.*D22.*S11.*S33 - B22.*D22.*S22.*S33 - A22.*B22.*D22.*S11.*S23.^2 - A22.*B22.*D22.*S13.^2.*S22 - A22.*B22.*D22.*S12.^2.*S33 + 2.*A22.*B22.*D22.*S12.*S13.*S23 + A22.*B22.*D22.*S11.*S22.*S33 - 1)-c31; (A22.*B11.*S11 - B21.^2.*S22 - B11 + B11.*B22.*S22 + B11.*D22.*S33 - A22.*B21.^2.*S12.^2 - B21.^2.*D22.*S23.^2 + A22.*B11.*B22.*S12.^2 + A22.*B11.*D22.*S13.^2 + B11.*B22.*D22.*S23.^2 + A22.*B21.^2.*S11.*S22 + B21.^2.*D22.*S22.*S33 + A22.*B21.^2.*D22.*S11.*S23.^2 + A22.*B21.^2.*D22.*S13.^2.*S22 + A22.*B21.^2.*D22.*S12.^2.*S33 - A22.*B11.*B22.*S11.*S22 - A22.*B11.*D22.*S11.*S33 - B11.*B22.*D22.*S22.*S33 - A22.*B11.*B22.*D22.*S11.*S23.^2 - A22.*B11.*B22.*D22.*S13.^2.*S22 - A22.*B11.*B22.*D22.*S12.^2.*S33 - 2.*A22.*B21.^2.*D22.*S12.*S13.*S23 - A22.*B21.^2.*D22.*S11.*S22.*S33 + 2.*A22.*B11.*B22.*D22.*S12.*S13.*S23 + A22.*B11.*B22.*D22.*S11.*S22.*S33)./(A22.*S11 + B22.*S22 + D22.*S33 + A22.*B22.*S12.^2 + A22.*D22.*S13.^2 + B22.*D22.*S23.^2 - A22.*B22.*S11.*S22 - A22.*D22.*S11.*S33 - B22.*D22.*S22.*S33 - A22.*B22.*D22.*S11.*S23.^2 - A22.*B22.*D22.*S13.^2.*S22 - A22.*B22.*D22.*S12.^2.*S33 + 2.*A22.*B22.*D22.*S12.*S13.*S23 + A22.*B22.*D22.*S11.*S22.*S33 - 1)-c22; -(B21.*D21.*(S23 + A22.*S12.*S13 - A22.*S11.*S23))./(A22.*S11 + B22.*S22 + D22.*S33 + A22.*B22.*S12.^2 + A22.*D22.*S13.^2 + B22.*D22.*S23.^2 - A22.*B22.*S11.*S22 - A22.*D22.*S11.*S33 - B22.*D22.*S22.*S33 - A22.*B22.*D22.*S11.*S23.^2 - A22.*B22.*D22.*S13.^2.*S22 - A22.*B22.*D22.*S12.^2.*S33 + 2.*A22.*B22.*D22.*S12.*S13.*S23 + A22.*B22.*D22.*S11.*S22.*S33 - 1)-c32; (A22.*D11.*S11 - D21.^2.*S33 - D11 + B22.*D11.*S22 + D11.*D22.*S33 - A22.*D21.^2.*S13.^2 - B22.*D21.^2.*S23.^2 + A22.*B22.*D11.*S12.^2 + A22.*D11.*D22.*S13.^2 + B22.*D11.*D22.*S23.^2 + A22.*D21.^2.*S11.*S33 + B22.*D21.^2.*S22.*S33 + A22.*B22.*D21.^2.*S11.*S23.^2 + A22.*B22.*D21.^2.*S13.^2.*S22 + A22.*B22.*D21.^2.*S12.^2.*S33 - A22.*B22.*D11.*S11.*S22 - A22.*D11.*D22.*S11.*S33 - B22.*D11.*D22.*S22.*S33 - A22.*B22.*D11.*D22.*S11.*S23.^2 - A22.*B22.*D11.*D22.*S13.^2.*S22 - A22.*B22.*D11.*D22.*S12.^2.*S33 - 2.*A22.*B22.*D21.^2.*S12.*S13.*S23 - A22.*B22.*D21.^2.*S11.*S22.*S33 + 2.*A22.*B22.*D11.*D22.*S12.*S13.*S23 + A22.*B22.*D11.*D22.*S11.*S22.*S33)./(A22.*S11 + B22.*S22 + D22.*S33 + A22.*B22.*S12.^2 + A22.*D22.*S13.^2 + B22.*D22.*S23.^2 - A22.*B22.*S11.*S22 - A22.*D22.*S11.*S33 - B22.*D22.*S22.*S33 - A22.*B22.*D22.*S11.*S23.^2 - A22.*B22.*D22.*S13.^2.*S22 - A22.*B22.*D22.*S12.^2.*S33 + 2.*A22.*B22.*D22.*S12.*S13.*S23 + A22.*B22.*D22.*S11.*S22.*S33 - 1)-c33];
format long gSfinal = fsolve(@funs,(1+i)*ones(1,6))Equation solved.fsolve completed because the vector of function values is near zeroas measured by the default value of the function tolerance, andthe problem appears regular as measured by the gradient.<stopping criteria details>Sfinal =Columns 1 through 3 -0.0576463452402932 - 0.0753664180207837i -0.0744682052419572 - 0.0630375797716533i -0.0698118920703255 - 0.0672129482711116iColumns 4 through 6 -0.185173231731065 + 0.109260636702373i -0.183468124937688 + 0.10862578397362i -0.186854054845906 + 0.104967752613526i
funs(Sfinal)ans = 2.04330996567137e-12 + 8.08547673258886e-13i 2.06829562157673e-12 + 8.28642710004601e-13i 2.07329856408145e-12 + 8.41465785939022e-13i 2.07303618715571e-12 + 7.6394446324457e-13i 2.08355208086708e-12 + 8.14071032806396e-13i 2.05693795329864e-12 + 7.88147325181399e-13i
Best Answer