Matlab怎样用数组作为一个for循环的变量
2个回答
展开全部
代码如下
clc
clear;
xx=[0 0.0635 0.1269 0.1904 0.2539 0.3173 0.3808 0.4443 0.5077 0.5712 0.6347 0.6981 0.7616 0.8251 0.8885 0.9520 1.0155 1.0789 1.1424 1.2059 1.2693 1.3328 1.3963 1.4597 1.5232 1.5867 1.6501 1.7136 1.7771 1.8405 1.9040 1.9675 2.0309 2.0944 2.1579 2.2213 2.2848 2.3483 2.4117 2.4752 2.5387 2.6021 2.6656 2.7291 2.7925 2.8560 2.9195 2.9829 3.0464 3.1099 3.1733 3.2368 3.3003 3.3637 3.4272 3.4907 3.5541 3.6176 3.6811 3.7445 3.8080 3.8715 3.9349 3.9984 4.0619 4.1253 4.1888 4.2523 4.3157 4.3792 4.4427 4.5061 4.5696 4.6331 4.6965 4.7600 4.8235 4.8869 4.9504 5.0139 5.0773 5.1408 5.2043 5.2677 5.3312 5.3947 5.4581 5.5216 5.5851 5.6485 5.7120 5.7755 5.8389 5.9024 5.9659 6.0293 6.0928 6.1563 6.2197 6.2832];
xxx=zeros(size(xx));
c=0;
for x=xx
if 0=<x<=pi
y=atan(sin(x)./(cos(x)+2.6));
w=10*sqrt(sin(x)^2+(cos(x)+2.6)^2);
F=w^2.*(6.88*y.*sin(y)-0.036*cos(y));
else
y=atan(sin(x)./(cos(x)+2.6));
w=8.4*sqrt(sin(x)^2+(cos(x)+2.6)^2); F=w^2.*(6.88*y.*sin(y)-0.036*cos(y));
end
c=c+1;
xxx(c)=F;
f(c)=(180*x)/pi;
end
plot(f,xxx);
clc
clear;
xx=[0 0.0635 0.1269 0.1904 0.2539 0.3173 0.3808 0.4443 0.5077 0.5712 0.6347 0.6981 0.7616 0.8251 0.8885 0.9520 1.0155 1.0789 1.1424 1.2059 1.2693 1.3328 1.3963 1.4597 1.5232 1.5867 1.6501 1.7136 1.7771 1.8405 1.9040 1.9675 2.0309 2.0944 2.1579 2.2213 2.2848 2.3483 2.4117 2.4752 2.5387 2.6021 2.6656 2.7291 2.7925 2.8560 2.9195 2.9829 3.0464 3.1099 3.1733 3.2368 3.3003 3.3637 3.4272 3.4907 3.5541 3.6176 3.6811 3.7445 3.8080 3.8715 3.9349 3.9984 4.0619 4.1253 4.1888 4.2523 4.3157 4.3792 4.4427 4.5061 4.5696 4.6331 4.6965 4.7600 4.8235 4.8869 4.9504 5.0139 5.0773 5.1408 5.2043 5.2677 5.3312 5.3947 5.4581 5.5216 5.5851 5.6485 5.7120 5.7755 5.8389 5.9024 5.9659 6.0293 6.0928 6.1563 6.2197 6.2832];
xxx=zeros(size(xx));
c=0;
for x=xx
if 0=<x<=pi
y=atan(sin(x)./(cos(x)+2.6));
w=10*sqrt(sin(x)^2+(cos(x)+2.6)^2);
F=w^2.*(6.88*y.*sin(y)-0.036*cos(y));
else
y=atan(sin(x)./(cos(x)+2.6));
w=8.4*sqrt(sin(x)^2+(cos(x)+2.6)^2); F=w^2.*(6.88*y.*sin(y)-0.036*cos(y));
end
c=c+1;
xxx(c)=F;
f(c)=(180*x)/pi;
end
plot(f,xxx);
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询