I am trying to convert a MATLAB code in Python. I don\'t know how to initialize empty matrix in Python.
MATLAB Code:
demod4(1) = [];
<
What about initializing a list, populating it, then converting to an array.
demod4 = []
Or, you could just populate at initialization using a list comprehension
demod4 = [[func(i, j) for j in range(M)] for i in range(N)]
Or, you could initialize an array of all zeros if you know the size of the array ahead of time.
demod4 = [[0 for j in range(M)] for i in range(N)]
or
demod4 = [[0 for i in range(M)]*N]
Or try using numpy
.
import numpy as np
N, M = 100, 5000
np.zeros((N, M))