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)
Amjed A
Amjed A on 23 Apr 2014
Closed: MATLAB Answer Bot on 20 Aug 2021
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
Walter Roberson on 24 Apr 2014
I do not follow the reason you are using degrees instead of radians ?
Walter Roberson
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)

Amjed A
Amjed A on 24 Apr 2014
why no answer
  5 Comments
Amjed A
Amjed A on 25 Apr 2014
Edited: Amjed A on 25 Apr 2014
i am saying that the answers i get after making the error 1e-2 is good and right. but i need to know if there is a better way of solving these equations because in another part ((when i change the values of B)) of my code , my iteration process also went to infinity !!
Amjed A
Amjed A on 25 Apr 2014
and sorry for your stone Mr.Walter. it is very important to drink a large amount of water in morning just after you wake up. i was having stones and the water made me better.

Amjed A
Amjed A on 26 Apr 2014
is it very hard question ??!!! no one help

Roger Stafford
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.
  2 Comments
Amjed A
Amjed A on 27 Apr 2014
thanks for help; but in the example you gave you use one equation !! this is not iterative process and you have just one variable !! but ok i tried the "fsolve" and i will retry it today and will give the feedback
Amjed A
Amjed A on 27 Apr 2014
how can input the given values of B and G in the function ? when i run the function he said that B and G are undefined !! while they are already defined in the program

Amjed A
Amjed A on 28 Apr 2014
i really disappointed with this site

Amjed A
Amjed A on 3 May 2014
hey any answer

Community Treasure Hunt

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

Start Hunting!