How to solve 2 equations with 2 unknowns and for Loop

5 views (last 30 days)
Hi
I have two equations with 2 unknowns K_23 and nu_12.
And I would like to solve these equations but for different V_f(i) value for each i
Thanks
lambda_0=7.0246;
mu_0=1.3380;
nu_0=0.42;
A_3=-3.0399;
A_4=1.0302;
A=-0.8873;
E_11=53.3299;
E_22=5.3694;
G_23=1.5959;
syms K_23 nu_12
for i =1:1:200
V_f(i)=i*0.005;
eq1(i)= K_23(i)== (lambda_0+mu_0)*((1+nu_0)*(1-2*nu_0))/ ...
( 1-nu_0*(1+2*nu_12(i))+V_f(i)*(2*(nu_12(i)-nu_0)*A_3(i)+(1-nu_0*(1+2*nu_12(i)))*A_4(i))/A(i));
eq2(i)= nu_12(i)^2== ((E_11(i)/E_22(i))-(E_11(i)/4)*((1/mu_23(i))+(1/K_23(i))));
sol(i)=solve(eq1(i),eq2(i))
K23value(i)=double(sol.K_23(i))
nu12value(i)=double(sol.nu_12(i))
end

Answers (1)

darova
darova on 8 Jul 2020
Edited: darova on 8 Jul 2020
  • remove all (i) parts
  • try vpasolve (numerical solver) insteaf of solve (symbolical solver). Your equations can be too complicated for symbolical solver
  2 Comments
Marwane Rouway
Marwane Rouway on 10 Jul 2020
I have solved these equations systems using vpasolve
Now. I need to know How can I extract one acceptible number from the solutions (we have two numbers as solutions). Then I need to put it in a table
Thank you very much
syms K_23 nu_12
eq1= K_23== (lambda_0+mu_0)*((1+nu_0)*(1-2*nu_0))/ ...
(1-nu_0*(1+2*nu_12)+V_f(i)*(2*(nu_12-nu_0)*A_3(i)+(1-nu_0*(1+2*nu_12))*A_4(i))/A(i));
eq2= nu_12^2== ((E_11(i)/E_22(i))-(E_11(i)/4)*((1 /mu_23(i))+(1/K_23)));
sol(i)=vpasolve([eq1 eq2],[K_23 nu_12],'Random',true);
K23value=sol(i).K_23;
nu12value=sol(i).nu_12;
F=table([sol(:).nu_12])
F.Properties.VariableNames = {'nu_12'}
writetable(F,'nu_12.xlsx')

Sign in to comment.

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!