Iteration issue in a system of equations

1 view (last 30 days)
Hello all :)
I am trying to solvea system of 3 equations with 10 iterations on beta_i_real_analysis (assuming its first value):
TSR=7.5; %Tip Speed Ratio
x=linspace(1,TSR,10)';
%a, a', beta_i
syms a_real_an a_prime_real_an beta_i_real_an
a_real_analysis = zeros(size(x));
a_prime_real_analysis = zeros(size(x));
beta_i_real_analysis = zeros(size(x));
% -C.2 Assume beta_i-
beta_i_real_analysis(1)=beta_i_real_design(1);
% >> beta_i_real_design(1)
%
% ans =
%
% 41.7895
alpha_real_analysis = zeros(size(x));
psi_real_analysis=psi_real_design;
% psi_real_design =
%
% 38.9995
% -46.4215
% -62.5481
% -43.6856
% 88.6155
% 44.5877
% -150.2246
% 97.7950
% -24.6071
% -7.5110
f = zeros(size(x));
k_real_analysis = zeros(size(x));
F_real_analysis = zeros(size(x));
for i = 1:numel(x)
% -C.3 Angle of attack-
alpha_real_analysis(i)=beta_i_real_analysis(i)-psi_real_analysis(i);
%f Function
f(i)=Z/(2*r_radius(i)*tan(beta(i)))-1/2;
%k Prandt Factor
k_real_analysis(i)=(2/pi)*acos(cosh(f(i)*r_radius(i))/cosh(f(i)));
%F Loading Force
F_real_analysis(i)=(Z*c_radius_real_design(i)*C_Ldesign)/(r_radius(i));
% -C.4 Induction factors (a, a')-
eqn_4 = a_real_an/(1-a_real_an)==(F_real_analysis(i)*cos(beta_i_real_an)*(1+eps_design*tan(beta_i_real_an)))/(8*pi*k_real_analysis(i)*(sin(beta_i_real_an))^2);
eqn_5 = a_prime_real_an/(1+a_prime_real_an)==(F_real_analysis(i)*(1-eps_design*cot(beta_i_real_an)))/(8*pi*k_real_analysis(i)*cos(beta_i_real_an));
eqn_6 = tan(beta_i_real_an)==(1-a_real_an)/(x(i)*(1+a_prime_real_an));
eqns2=[eqn_4,eqn_5,eqn_6];
S_an=vpasolve(eqns2,[a_real_an a_prime_real_an beta_i_real_an]);
a_real_analysis(i)=S_an.a_real_an;
a_prime_real_analysis(i)=S_an.a_prime_real_an;
beta_i_real_analysis(i)=S_an.beta_i_real_an;
end
...but I have this error message:
Unable to perform assignment because the left and right sides have a different number of elements.
Error in Assigment1 (line 296)
a_real_analysis(i)=S_an.a_real_an;
Indeed, when I tested the sizes of the left side element and the right side element, it was not the same:
>> numel(a_real_analysis(1))
ans =
1
>> numel(S_an.a_real_an)
ans =
0
I guess there is a problem in my equations, so it finds no solution, but I don't understand why.
I saw there is a problem with the iteration of beta_i_real_analysis. The first value has been recalculated and is not equal to beta_i_real_design(1) anymore.
>> beta_i_real_design(1)
ans =
41.7895
>> beta_i_real_analysis(1)
ans =
-46.1747
I put the full code in the attachement, just in case.
Thanks for your help ! :)
  3 Comments
Bertrand Canetti
Bertrand Canetti on 23 Mar 2019
Oh right, sorry. I have just added it. :)
Walter Roberson
Walter Roberson on 23 Mar 2019
The problem is not in the equations; the problem is that MATLAB is not powerful enough to solve these equations.
The solutions involve the roots of a quartic that has two real and two complex roots. The real branches lead to approximately
a_prime_real_an = -0.02474146999, a_real_an = -0.285924183, beta_i_real_an = -2.814701526
a_prime_real_an = -0.02440758759, a_real_an = 1.273966783, beta_i_real_an = 3.069506676
You might be able to get further solving iteratively -- that is, solve() the first equation for the first variable, substitute in to the second equation, solve for the second variable, substitute both in the third equation, and that would probably be the step at which you encountered the problem
The quartic involved is
53316167837240733282943225387833161867395787192374658735269509559585079296*Z^4 - 2579284664294367540994985140973959543195082867280625499181867434732683264*Z^3 - 103294395418203027542989161718870901309488050539553695010936278305466998278*Z^2 + 2579284664294367540994985140973959543195082867280625499181867434732683264*Z + 50007453120020265071916601547099470636596849565193438461713839085701304711

Sign in to comment.

Answers (0)

Community Treasure Hunt

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

Start Hunting!