Initialize empty matrix in Python

前端 未结 7 1333
旧巷少年郎
旧巷少年郎 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:33

    rows = 3
    columns = 2
    M = [[0]*columns]*rows
    

    Or you could also use '' instead of 0

    print(M)
    

    Output:

    M = [[0, 0], [0, 0], [0, 0]] 
    

提交回复
热议问题