Initialize empty matrix in Python

前端 未结 7 1347
旧巷少年郎
旧巷少年郎 2020-12-31 07:56

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) = [];
<
7条回答
  •  暗喜
    暗喜 (楼主)
    2020-12-31 08:38

    You could use a nested list comprehension:

    # size of matrix n x m
    matrix = [ [ 0 for i in range(n) ] for j in range(m) ]
    

提交回复
热议问题