I want to write in python the equivalent to this code in Matlab,
zeta = zeros(1,5)
alpha=[1e5,1e3,1e5,1e7,1e3];
dz = 0.001;
for i=1:length(zeta)
zeta(i) = alpha(i)/(dz*dz);
end
EDIT:
Thank for all answers, they are all very useful and are helping understanding how python works, and seems Matlab too; because I’m not getting the full potencial of array and matrix operation. My initial programming language is C.
Now, I’m trying to figure how to code in python cycles and array operations. If you can help. (zeta is from the previous code)
nl= 7;
l=[0.3,0.1,0.2,0.1,0.1,0.1,0.3)
wz=zeros(1,nl); %layer width
temp=0; %auxiliary temp variable
for i=1:nl
wz(i)=l(1,i)*(nz-1)+temp;
temp=wz(1,i);
end
1 Answer