我试图在MATLAB中重写一些python代码,python代码如下:
theta = 0:pi/510:2*pi;
phi = pi/3:2*pi/360:6*pi;
phi_outer = np.linspace(CV.Outer.phi_min, CV.Outer.phi_max, 100)
phi_inner = np.linspace(CV.Inner.phi_max, CV.Inner.phi_min, 100)
x1, y1 = coords(phi_outer, geo, theta, CV.Outer.involute)
t = np.linspace(0,1,100)
x3, y3 = coords(phi_inner, geo, theta, CV.Inner.involute)
x2 = (x3[0]-x1[-1])*t+x1[-1]
y2 = (y3[0]-y1[-1])*t+y1[-1]
x4 = (x1[0]-x3[-1])*t+x3[-1]
y4 = (y1[0]-y3[-1])*t+y3[-1]
我的MATLAB转换尝试:
^{pr2}$X2
,y2
,x4
,y4
绝对不正确,但我不明白这里的意思x3 [0] -x1 [-1]
)。。。所以在MATLAB中,数组以x3(1)
开头,而不是{x2
,y2
,x4
,y4
。在
MATLAB索引从
1
开始,而不是像python那样从0
开始其中每个元素基本上被索引为
MATLABindex = PythonIndex-1
,而且,正如其他人已经提到的,MATLAB选择数组中最后一个元素的方法是end
语法
x[-1]
索引Python中数组中的最后一个元素。在要在MATLAB中实现这一点,可以使用
end
关键字相关问题 更多 >
编程相关推荐