Octave 不以八度音阶绘制的线

Octave 不以八度音阶绘制的线,octave,Octave,我被指示用矩阵变换的点画一个圆。我似乎无法在所有的点之间划出一条线 c = cos(pi/8) s = sin(pi/8) A = [c -s; s c] xy = [1;0] axis('square') for i = 1:17 xy = A * xy; plot(xy(1, :), xy(2,:), 'r', 'linewidth', 2); hold on endfor 当我运行代码时,我得到了这个 我如何在所有点之间画线 谢谢在绘图之前,您需要计算所有点。如果一次只绘制

我被指示用矩阵变换的点画一个圆。我似乎无法在所有的点之间划出一条线

c = cos(pi/8)
s = sin(pi/8)
A = [c -s; s c]
xy = [1;0]
axis('square')
for i = 1:17
  xy = A * xy;
  plot(xy(1, :), xy(2,:), 'r', 'linewidth', 2);
  hold on
endfor
当我运行代码时,我得到了这个

我如何在所有点之间画线


谢谢

在绘图之前,您需要计算所有点。如果一次只绘制一个点,则该点无处可连接直线

c = cos(pi/8)
s = sin(pi/8)
A = [c -s; s c]
xy = zeros(2,17);   %// preallocate the matrix
xy(:,1) = [1;0]
for i = 2:17
  xy(:,i) = A * xy(:,i-1);
endfor

plot(xy(1, :), xy(2,:), 'r', 'linewidth', 2);
axis('square')   %// goes *after* the plot (thanks @Andy)

它为你画了线?我在Octave 3.8.2中没有画线。对不起@bicker是为其他人设计的,他们因为没有发布情节本身而删除了评论。由于某些原因,我在保存图形时遇到问题。顺便说一句,您必须在plot命令后放置“axis('square')。@Andy Yep,我的错。