主题:菜鸟求助
一个简单的循环
for n=1:10
x(n)=sin(n*pi/10);
end
x
结果应为x =
Columns 1 through 10
0.3090 0.5878 0.8090 0.9511 1.0000 0.9511 0.8090 0.5878 0.3090 0.0000
而运算结果为x =
Columns 1 through 10
0.3090 0.5878 0.8090 0.9511 1.0000 0.9511 0.8090 0.5878 0.3090 0.0000
Columns 11 through 20
-3.5510 -3.3061 -3.0612 -2.8163 -2.5714 -2.3265 -2.0816 -1.8367 -1.5918 -1.3469
Columns 21 through 30
-1.1020 -0.8571 -0.6122 -0.3673 -0.1224 0.1224 0.3673 0.6122 0.8571 1.1020
Columns 31 through 40
1.3469 1.5918 1.8367 2.0816 2.3265 2.5714 2.8163 3.0612 3.3061 3.5510
Columns 41 through 50
3.7959 4.0408 4.2857 4.5306 4.7755 5.0204 5.2653 5.5102 5.7551 6.0000
不知问题出在哪里,请大虾指教,谢了
for n=1:10
x(n)=sin(n*pi/10);
end
x
结果应为x =
Columns 1 through 10
0.3090 0.5878 0.8090 0.9511 1.0000 0.9511 0.8090 0.5878 0.3090 0.0000
而运算结果为x =
Columns 1 through 10
0.3090 0.5878 0.8090 0.9511 1.0000 0.9511 0.8090 0.5878 0.3090 0.0000
Columns 11 through 20
-3.5510 -3.3061 -3.0612 -2.8163 -2.5714 -2.3265 -2.0816 -1.8367 -1.5918 -1.3469
Columns 21 through 30
-1.1020 -0.8571 -0.6122 -0.3673 -0.1224 0.1224 0.3673 0.6122 0.8571 1.1020
Columns 31 through 40
1.3469 1.5918 1.8367 2.0816 2.3265 2.5714 2.8163 3.0612 3.3061 3.5510
Columns 41 through 50
3.7959 4.0408 4.2857 4.5306 4.7755 5.0204 5.2653 5.5102 5.7551 6.0000
不知问题出在哪里,请大虾指教,谢了