我將MATLAB代碼到Python代碼困難MATLAB到Python代碼轉換
function Xn = ReSampleCurve(X,N)
[n,T] = size(X);
del(1) = 0;
for r = 2:T
del(r) = norm(X(:,r) - X(:,r-1));
end
cumdel = cumsum(del)/sum(del);
newdel = [0:N-1]/(N-1);
for j=1:n
Xn(j,:) = interp1(cumdel,X(j,1:T),newdel,'linear');
end
我打算將它轉換成Python代碼
輸入值:
X = [[-9.035250067710876, 7.453250169754028, 33.34074878692627], [-6.63700008392334, 5.132999956607819, 31.66075038909912],[-5.1272499561309814, 8.251499891281128, 30.925999641418457], [-5.1272499561309814, 8.251499891281128, 30.925999641418457]]
N = 200
能有人向我解釋這些線是幹什麼的?
del(1) = 0;
for r = 2:T
del(r) = norm(X(:,r) - X(:,r-1));
你總是可以嘗試http://freemat.sourceforge.net/和運行matlab代碼自己看看... –