Why WHILE loop doesn't advance?
Mostra commenti meno recenti
function cam()
clc
clear all
close all
N_i = input('N de intervalos:');
k=1;
while(k<=N_i)
k
beta_i(k) = input('Beta do intervalo:');
L(k) = input('Lift do intervalo:');
mov(k) = input('Movimento do intervalo:');
k=k+1;
end
R_0 = input('Raio base:');
tb_i=0;
tb_f=1;
teta=0;
passo=1;
n=1;
T(n)=teta;
j=1;
while(j<=N_i)
j
switch mov(j)
case 1
while(teta<=beta_i(j))
y=0.5*L(j)*(1-cos(pi*teta/beta_i(j)));
dy=((pi*L(j))/(2*beta_i(j)))*sin(pi*teta/beta_i(j));
u=(R_0+y)*sin(teta)+dy*cos(teta);
v=(R_0+y)*cos(teta)-dy*sin(teta);
T(n)=teta;
A(n,:,j)=[y,dy,j]
P(n,:,j)=[u,v,j]
n=n+1;
teta=teta+passo;
end
case 2
while(teta<=beta_i(j))
y=L(j)*((teta/beta_i(j))-sin(2*pi*(teta/beta_i(j))));
dy=(L(j)/beta_i(j))*(1-cos(2*pi*(teta/beta_i(j))));
u=(R_0+y)*sin(teta)+dy*cos(teta);
v=(R_0+y)*cos(teta)-dy*sin(teta);
T(n)=teta;
A(n,:,j)=[y,dy,j]
P(n,:,j)=[u,v,j]
n=n+1;
teta=teta+passo;
end
end
j=j+1;
end
end
Why the "while(j<=N_i)" loop only computes A and P for j=1 and doesn't advance after that? Can't understand...
5 Commenti
Adam
il 1 Nov 2016
Well, for a start we have no idea what N_i is since it is a user input.
Miguel Viegas Leal
il 1 Nov 2016
Miguel Viegas Leal
il 1 Nov 2016
Image Analyst
il 1 Nov 2016
Can you give typical numbers for all 5 user inputs, not just one, so we know what to enter and can try your code?
Miguel Viegas Leal
il 1 Nov 2016
Risposta accettata
Più risposte (1)
Image Analyst
il 1 Nov 2016
It worked for me:
N de intervalos:2
k =
1
Beta do intervalo:3
Lift do intervalo:3
Movimento do intervalo:4
k =
2
Beta do intervalo:5
Lift do intervalo:6
Movimento do intervalo:7
Raio base:0
j =
1
j =
2
3 Commenti
Miguel Viegas Leal
il 1 Nov 2016
Image Analyst
il 1 Nov 2016
That also does both j. Look:
N de intervalos:2
k =
1
Beta do intervalo:180
Lift do intervalo:3
Movimento do intervalo:1
k =
2
Beta do intervalo:90
Lift do intervalo:2
Movimento do intervalo:2
Raio base:0.025
j =
1
j =
2
Miguel Viegas Leal
il 1 Nov 2016
Modificato: Miguel Viegas Leal
il 1 Nov 2016
Categorie
Scopri di più su Dates and Time in Centro assistenza e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!