[英]3D Vector Plot Gone Wrong
I have written a script in Octave below based off of a post: How to draw vectors (physical 2D/3D vectors) in MATLAB? 我基于以下文章在Octave中编写了一个脚本: 如何在MATLAB中绘制矢量(物理2D / 3D矢量)?
I have the following code in Octave and I get the error ' "vector" undefined near line 3 column 1' 我在Octave中有以下代码,并且在第3行第1列附近得到了错误““ vector”未定义”
Can anyone help me? 谁能帮我? I have written a few other *.m files for Octave with no problem and now I am stuck. 我已经为Octave编写了其他一些* .m文件,但没有任何问题,现在我陷入了困境。
a = [0 0 1]; %# Vector 1
b = [0.894 0 0.447]; %# Vector 2
c = [0.276 0.851 0.447]; %# Vector 3
d = [-0.724 0.526 0.447]; %# Vector 4
e = [-0.724 -0.526 0.447]; %# Vector 5
f = [0.276 -0.851 0.447]; %# Vector 6
g = [0.724 0.526 -0.447]; %# Vector 7
h = [-0.276 0.851 -0.447]; %# Vector 8
i = [-0.894 0 -0.447]; %# Vector 9
j = [-0.276 -0.851 -0.447] %# Vector 10
k = [0.724 -0.526 -0.447]; %# Vector 11
l = [0 0 -1]; %# Vector 12
starts = zeros(3,3);
ends = [a;b;c;d;e;f;g;h;i;j;k;l];
quiver3(starts(:,1), starts(:,2), starts(:,3), starts(:,4), starts(:,5),
starts(:,6), starts(:,7), starts(:,8), starts(:,9), starts(:,10),
starts(:,11), starts(:,12), ends(:,1), ends(:,2), ends(:,3),
ends(:,4), ends(:,5), ends(:,6), ends(:,7), ends(:,8), ends(:,9),
ends(:,10), ends(:,11), ends(:,12), 0)
axis equal
This doesn't work because starts
is of size 3x3 and you are indexing it up to 12 on the column index. 这是行不通的,因为starts
的大小为3x3,并且您在列索引上最多将其索引为12。 The error message I get is: 我收到的错误消息是:
error: A(I,J): column index out of bounds; value 4 out of bound 3
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.