【发布时间】:2020-05-31 09:50:46
【问题描述】:
我有一些正在工作的 Octave/Matlab 代码,我正在尝试使其工作/转换为 Python 3.7.4,因此我可以在 使用 Python 3.7.4 的 Blender 2.82 中使用它。
工作的 Octave/Matlab 代码是:
c=[7,-2,-4,-8]
[rw col]= size(c); %get size a array
num_of_loops=5 %number of loops to iterate
a= zeros(num_of_loops,col); %allocate memory to array
b= zeros(1,(rw*col)); %allocate memory to array
a(1,:)=c; %add c array to 1st row in array
for n=1:num_of_loops
n
a = c .+ [c(end).*(0:4)].';
b = vec (a.', 2);
endfor
b=reshape(a',1,[]);
这给了我正确的输出:
c=
7 -2 -4 -8
a=
7 -2 -4 -8
-1 -10 -12 -16
-9 -18 -20 -24
-17 -26 -28 -32
-25 -34 -36 -40
b=
7 -2 -4 -8 -1 -10 -12 -16 -9 -18 -20 -24 -17 -26 -28 -32 -25 -34 -36 -40
(如果你需要 if / then / else 命令这里是original question。)
我尝试了online convert octave/matlab to python converter,它给了我下面的代码(它不能完全工作)。如何修复 Python 3.x 代码以使其在使用 Python 3.7.4 的 Blender 2.82 中工作?
c = mcat([7, -2, -4, -8]); print c
[rw, col] = size(c)#get size a array
num_of_loops = 5; print num_of_loops#number of loops to iterate
a = zeros(num_of_loops, col)#allocate memory to array
b = zeros(1, (rw * col))#allocate memory to array
a(1, mslice[:]).lvalue = c#add c array to 1st row in array
for n in mslice[1:num_of_loops]:
n()
mcat([c(end) *elmul* (mslice[0:4])]).T
b = vec(a.T, 2)
end
b = reshape(a.cT, 1, mcat([]))
【问题讨论】:
标签: python-3.x matlab octave blender