How can i fix this error?
조회 수: 1 (최근 30일)
이전 댓글 표시
for Z=-4:.5:3
alfa=0;
while alfa<=2*pi
A=[cos(alfa) -sin(alfa) 0;sin(alfa) cos(alfa) 0;0 0 1]; % Matriz de rotación en torno al eje Z
B=A*[(1/5)*sqrt(25+Z^2)+0.5,0,Z]';
x=B(1,1);
y=B(2,1);
z=B(3,1);
plot3(x,y,z,'.r')
hold on
alfa=alfa+pi/100;
end
end
n=linspace(-3,4,10);
dz=n(1,2)-n(1,1);
Vr1=0;
for i=2:101
Vr1=Vr1+pi*(1/5)*sqrt(25+(n(1,i)-dz/2)+0.5)^2*dz;
end
disp(["The volume is:", num2str(Vr1)])
댓글 수: 0
답변 (1개)
Matt J
2022년 3월 6일
You have a loop running from 2 to 101
for i=2:101
Vr1=Vr1+pi*(1/5)*sqrt(25+(n(1,i)-dz/2)+0.5)^2*dz;
end
but n has only 10 values. Should it have 101 values?
댓글 수: 0
참고 항목
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
