How to solve 2 equations with 2 unknowns and for Loop

조회 수: 2 (최근 30일)
Marwane Rouway
Marwane Rouway 2020년 7월 7일
댓글: Marwane Rouway 2020년 7월 10일
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

답변 (1개)

darova
darova 2020년 7월 8일
편집: darova 2020년 7월 8일
  • remove all (i) parts
  • try vpasolve (numerical solver) insteaf of solve (symbolical solver). Your equations can be too complicated for symbolical solver
  댓글 수: 2
Marwane Rouway
Marwane Rouway 2020년 7월 10일
Thank you
I appreciate this
Marwane Rouway
Marwane Rouway 2020년 7월 10일
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')

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Equation Solving에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by