I have this code in MATLAB and I am trying to convert it in Python.
M=zeros(1,N);
i=1;
while i<=N
ind=mod(p*(i-1)+1,N);
if ind==0
ind=N;
end
while M(ind)~=0
ind=ind+1;
end
M(ind)=i;
i=i+1;
ind=ind+1;
end
display(M);
M1=zeros(m,2/n_lay*n_wc);
for i=1:m
M1(i,:)=M(2/n_lay*n_wc*(i-1)+1:2/n_lay*n_wc*i);
end
I don't know how to convert the for loop and what I have until now is the code below, and I don't know exactly how to convert the line "M1(i,:) = M(2/n_layn_wc*(i-1)+1:2/n_layn_wci)*" here is the probleme where I get from Python "Invalid syntax".
import numpy, scipy, matplotlib
N = 24
p = 2
n_lay = 2
n_wc=1
M=zeros(1,N)
i=1;
while i<=N:
ind=mod(p*(i-1)+1,N)
if ind==0 :
ind=N
end
while M(ind)!=0:
ind=ind+1
end
M(ind)=i
i=i+1
ind=ind+1
end
display(M)
M1=zeros(m,2/n_lay*n_wc)
for i in range (1,m):
M1(i,:) = M(2/n_lay*n_wc*(i-1)+1:2/n_lay*n_wc*i)
end