loop while doesn't stop

Hi everybody,
I wrote a code related to a wind turbine exercice but my loop while does not stop and I don't understand why because it seems that stop conditions are fulfilled.
My loop while should stop when (a-a1=0) & (aprime-aprime1=0)
It would be great if you can have a look at my following code :
clear all
% Variable speed of the rotor
w=2.61;
% Air density 1.225 kg/m3
d=1.225;
% Rotor diameter 62 m
R=31;
% Number of blades 3
B=3;
% Cut in wind speed 5m/s
V0=15;
% local pitch
theta=0;
r=24.5;
Betat=2;
c1=1.09
erreur=1;
a=0;
aprime=0;
a1=0;
aprime1=0;
compteur=0;
while erreur>1e-3
compteur=compteur+1
a=a1;
aprime=aprime1;
phi=atan((1-a)*V0/((1+aprime)*w*r));
phi_deg=phi*180/pi;
alpha=phi_deg-(theta+Betat);
Cl=1;
Cd=0.001;
Cn=Cl*cos(phi)+Cd*sin(phi);
Ct=Cl*sin(phi)-Cd*cos(phi);
F=(2/pi)*acos(exp((-B/2)*(R-r)/(r*sin(phi))));
sigma=c1*B/(2*pi*r);
a=1/((4*(sin(phi))^2*F/(sigma*Cn))+1);
aprime=1/((4*sin(phi)*cos(phi)*F/(sigma*Ct))-1);
erreur=abs(abs(a-a1)+abs(aprime1-aprime));
matrix(compteur,1)=a
matrix(compteur,2)=aprime
matrix(compteur,3)=alpha
matrix(compteur,4)=phi_deg
matrix(compteur,5)=Cn
matrix(compteur,6)=Ct
end
Kind regards

2 commentaires

Jan
Jan le 25 Sep 2011
Please use proper code formatting to improve the readability. Follow the "Markup help" link to learn the details.
See this link about avoiding CLEAR ALL:
http://www.mathworks.com/matlabcentral/answers/16484-good-programming-practice#answer_22301
Andrei Bobrov
Andrei Bobrov le 25 Sep 2011
so?
a1=1/((4*(sin(phi))^2*F/(sigma*Cn))+1);

Connectez-vous pour commenter.

Réponses (1)

Jan
Jan le 25 Sep 2011

0 votes

Your code creates the same values in each iteration, because you initialize a to a1 and aprime to aprime1 repeatedly. Please use a debugger to check this: Set a breakpoint in the code and step through your program line by line.

Catégories

En savoir plus sur MATLAB dans Centre d'aide et File Exchange

Question posée :

le 25 Sep 2011

Community Treasure Hunt

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

Start Hunting!

Translated by