Info
This question is closed. Reopen it to edit or answer.
how can i solve these equations to get the variables??
1 view (last 30 days)
Show older comments
hi; i am working on my thesis and i made an iteration process to solve these equations for x(i),a(i),b(i),Cx(i),Cy(i),Cl(i) and Cd(i). all other variables that you seen are just given before this sector of the code. and i made the wanted variables as vectors in the first so matlab can deal with them as vectors just that. the problem is that matlab is giving me the answer for (i=5:10), but for(i=1:4) the answer is not coming and the iteration process goes to infinity. is there any other way to solve these equations ?? like dealing with them as simultaneous equations or is there a code to solve them?? thank you for help
if true
% code
end
x=[1:10]; Cl=[1:10]; Cd=[1:10]; a=[1:10]; b=[1:10];
Cx=[1:10]; Cy=[1:10]
for i=1:10
a(i)=0; b(i)=0;
diff_a=1; diff_b=1;
iteration_count=0;
while diff_a >= 1e-7 || diff_b >= 1e-7
x(i)=(atand((1-a(i))/((1+b(i))*H*(i/10))))-B(i);
if x(i)<= 20
Cl(i)= -0.0004*x(i)^3 + 0.0059*x(i)^2 + 0.0759*x(i) + 0.0097;
else
Cl(i)= 6*10^(-6)*x(i)^3 - 0.0015*x(i)^2 + 0.101*x(i) - 0.9405;
end
Cd(i)= -5*10^(-6)*x(i)^3 + 0.0006*x(i)^2 - 0.0018*x(i) - 0.0045;
Cx(i)=(Cl(i))*cosd(x(i)+B(i))+(Cd(i))*sind(x(i)+B(i));
Cy(i)=(Cl(i))*sind(x(i)+B(i))-(Cd(i))*cosd(x(i)+B(i));
a_next = 1/(((4*sind(x(i)+B(i))*sind(x(i)+B(i)))/(G(i)*Cx(i)))+1);
b_next = 1/(((4*sind(x(i)+B(i))*cosd(x(i)+B(i)))/(G(i)*Cy(i)))+1);
diff_a = abs(a_next - a(i));
diff_b = abs(b_next - b(i));
a(i) = a_next;
b(i) = b_next;
iteration_count = iteration_count + 1
end
end
2 Comments
Walter Roberson
on 24 Apr 2014
I do not follow the reason you are using degrees instead of radians ?
Walter Roberson
on 24 Apr 2014
I can't really mentally simulate this without an idea of the range of the values in B(1:5), or the value in H.
Answers (5)
Roger Stafford
on 26 Apr 2014
I see no reason to believe that the iterative procedure you have set up will necessarily converge. You were lucky with B(i) and G(i) for i from 5 to 10, but it clearly failed to converge for 1 to 4. You need to use matlab's symbolic 'solve' function or the numerical 'fsolve' function to find a simultaneous solution for all seven equations, rather than this apparently blind iteration.
Just to give you a very simple iteration that will fail, suppose you want to solve for the single unknown x in the equation
x = -2*x + 3
and suppose we naively start with x(1) = 0 and do the iteration
x(n+1) = -2*x(n) + 3
in the hope that it will eventually converge to the answer x = 1. Unfortunately, it does this instead:
x = 0,3,-3,9,-15,33,-63,...
and is clearly never going to arrive at the correct answer.
I claim that your iteration with the seven equations and seven unknowns is similar in concept to this simple example. You have no reason to suppose that it will successfully converge.
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!