problem with For loop

3 vues (au cours des 30 derniers jours)
Villanova
Villanova le 31 Oct 2012
Hi, i have written this code, but not sure why I don't get anything in my plot. I was wondering if someone could point out what I doing wrong. I am pretty much trying to plot values for certain v_dot values.
global x1lco x2lco
alpha12 = -2.086211466368665;
alpha22 = 1.378057393962953;
alpha11 = -0.082454051332553;
alpha21 = 0.395565864578256;
alpha0 = 0.641764119934185;
g = (x1lco.^2 + x2lco.^2).^2 + alpha12.*x1lco.^2 + alpha22.*x2lco.^2 + alpha11.*x1lco + alpha21.*x2lco + alpha0;
i = 0
for phi = 0:.01:2*pi;
flag = 0;
i = i + 1;
j = 0;
for r = .01:0.01:3;
j = j + 1;
v_dot = -1.*r.^2.*(g + 2.*(alpha22 - alpha12).*sin(phi).*cos(phi)) -1.*r.*(alpha21.*cos(phi)- alpha11.*sin(phi));
if v_dot >=0 & flag == 0
r_b(i) = r;
phi_b(i) = phi;
flag = 1
end
end
end
x1 = r.*cos(phi);
x2= r.*sin(phi);
plot (x2,x1)

Réponse acceptée

Kye Taylor
Kye Taylor le 31 Oct 2012
You are only plotting a single point... That is, the variables r and phi are only scalars (1x1 doubles) when you define x1 and x2. Therefore x1 and x2 are also simply scalars.

Plus de réponses (0)

Catégories

En savoir plus sur Loops and Conditional Statements dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by