How can I use for loop twice
3 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
omkar bichkar
il 13 Giu 2015
Modificato: Azzi Abdelmalek
il 13 Giu 2015
error: for | Error: Expression or statement is incomplete or incorrect.
syms x
Fun = (sqrt(7.447.*(200-x).*(2.0720.*x-200.*sqrt(9.01)+sqrt(9.01.*200^2- 7.9810*200.*x))))/8;
h=1;
zi = 1:360;
x=0:h:200;
Fun1 = matlabFunction(Fun);
for i=1:(length(x)-1)
for
j=1:360
end
y1 = Fun1(x(i));
z1 = Fun1(x(i));
x2 = x(i)+h;
y2 = Fun1(x(i+1));
z2 = Fun1(x(i+1));
x3 = x(i)+h;
y3 = y2*cos((pi/180)*zi(j));
z3 = z2*sin((pi/180)*zi(j));
T1 = [0, y3-y2, z3-z2];
T2 = [x(i)-x(i+1), y1-y2, z1-z2];
Vec = cross(T1,T2);
deltal = sqrt((y2-y1)^2+h^2);
deltazi = sqrt(z3^2+(y2-y3)^2);
dA11 = deltal.*deltazi;
end
please help me
0 Commenti
Risposta accettata
Azzi Abdelmalek
il 13 Giu 2015
Modificato: Azzi Abdelmalek
il 13 Giu 2015
Look at this part of your code
for
j=1:360
end
It's not correct, and even it's corrected
for j=1:360
end
This doesn't mean anything, maybe what you want is this:
syms x
Fun = (sqrt(7.447.*(200-x).*(2.0720.*x-200.*sqrt(9.01)+sqrt(9.01.*200^2- 7.9810*200.*x))))/8;
h=1;
zi = 1:360;
x=0:h:200;
Fun1 = matlabFunction(Fun);
for i=1:(length(x)-1)
y1 = Fun1(x(i));
z1 = Fun1(x(i));
x2 = x(i)+h;
y2 = Fun1(x(i+1));
z2 = Fun1(x(i+1));
x3 = x(i)+h;
for j=1:360
y3 = y2*cos((pi/180)*zi(j));
z3 = z2*sin((pi/180)*zi(j));
T1 = [0, y3-y2, z3-z2];
T2 = [x(i)-x(i+1), y1-y2, z1-z2];
Vec = cross(T1,T2);
deltal = sqrt((y2-y1)^2+h^2);
deltazi = sqrt(z3^2+(y2-y3)^2);
dA11 = deltal.*deltazi;
end
end
0 Commenti
Più risposte (1)
Mischa Kim
il 13 Giu 2015
Hi Omkar, looks like the second end is misplaced. Als, I recommend using ii instead of i (and same for j) because it is also used as the imaginary unit.
Fun1 = matlabFunction(Fun);
for i = 1:(length(x)-1) %%replace i by ii
for j = 1:360 %%replace j by jj
y1 = Fun1(x(i));
z1 = Fun1(x(i));
x2 = x(i)+h;
y2 = Fun1(x(i+1));
z2 = Fun1(x(i+1));
x3 = x(i)+h;
y3 = y2*cos((pi/180)*zi(j));
z3 = z2*sin((pi/180)*zi(j));
T1 = [0, y3-y2, z3-z2];
T2 = [x(i)-x(i+1), y1-y2, z1-z2];
Vec = cross(T1,T2);
deltal = sqrt((y2-y1)^2+h^2);
deltazi = sqrt(z3^2+(y2-y3)^2);
dA11 = deltal.*deltazi;
end
end
0 Commenti
Vedere anche
Categorie
Scopri di più su Calculus in Help Center e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!