How can I use for loop twice
4 次查看(过去 30 天)
显示 更早的评论
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 个评论
采纳的回答
Azzi Abdelmalek
2015-6-13
编辑:Azzi Abdelmalek
2015-6-13
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 个评论
更多回答(1 个)
Mischa Kim
2015-6-13
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 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Calculus 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!