'solving system of 16 nonlinear equations with 16 unknowns

I am trying to solve a system of 16 nonlinear equations that has 16 unknowns using lsqnonlin.

my variables are all depend on other equations (exp: SegmaD is unknown and defined as (SegmaD= EpR2Teta) then (Teta= fcr-Epcr/2*FT) then Epcr=EpA/TX and as you can see EPA has an if statement so I defined all the variables as symbolic, but I am getting errors that you can't use if statement with symbolic (I am a beginner in Matlab) so I want to construct my 16 equations by substituting other ones that has the unknowns to solve by lsqnonlin, how can I do that symbolically and then solve for a given value? what is the best way to approach this? I have attached a part of my code to give a brief understanding of what is going on. Thanks

code:

syms Tx EpDs EpR EpA EpL K1 SegmaR Teta SegmaD FT EpT q AlphaD GamaLT
SegmaR(i) = Fcr*(EpR(i)/Epcr);
Teta(i) = 0.9/(sqrt(1+600*EpR(i))); % Teta is the Softening Coefficient equation 17

% K1 equation 16
if (EpA(i) < EpDs(i))    
    K1(i)= ((EpDs(i)/Ep0)*(1-(EpDs(i)/3*Ep0))-((EpA(i))^2)/(EpDs(i)*Ep0))*(1-((EpA(i)/3*Ep0)))*(EpDs(i)/(EpDs(i)-EpA(i))); 
elseif (EpA(i)==EpDs(i))    
    K1(i)= ((2*EpDs(i)*Ep0)-EpDs(i)^2/Ep0^2); %K1 is a Dimensionless Parameter   
end

SegmaD(i) = K1(i)*Teta(i)*fck; % SegmaD is the evolution of concrete compressive stress equation 15

EpT(i) = EpR(i)+EpD(i)-EpL(i); %equation 14

FT(i) = (Es*EpT(i))*(0.002+((1-0.002)/(1+((1-0.002)*(EpT(i)/EpSy))^4)^0.25)); % Equation 21


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source