Skip to content
TheChatArchiveThe Chat Archive
gpt-3.5-turbo-0613· OpenAIAi2 WildChat-4.8M (AI2)

%%matlab自带函数 N=512 dftmtx(N)/sqrt(N); %%和上面的等同 psi=fft(eye(N))/sqrt(N); 将这段代码转换为python版本

  1. User

    %%matlab自带函数 N=512 dftmtx(N)/sqrt(N);

    %%和上面的等同 psi=fft(eye(N))/sqrt(N); 将这段代码转换为python版本

  2. Assistant

    import numpy as np

    N = 512 dftmtx = np.fft.fft(np.eye(N))/np.sqrt(N) psi = dftmtx

    print(psi)

  3. User

    %%使用rand函数产生0-1区间的数 function A=get01(N)

    B=rand(N,N); %将产生N行N列随机数矩阵 A=round(B); %将产生的矩阵四舍五入,即可得到非 0 即 1 的矩阵

    end 将这段代码转换为python版本

  4. Assistant

    import numpy as np

    def get01(N): B = np.random.rand(N,N) A = np.round(B) return A

    N = 5 result = get01(N) print(result)