程序師世界是廣大編程愛好者互助、分享、學習的平台,程序師世界有你更精彩!
首頁
編程語言
C語言|JAVA編程
Python編程
網頁編程
ASP編程|PHP編程
JSP編程
數據庫知識
MYSQL數據庫|SqlServer數據庫
Oracle數據庫|DB2數據庫
您现在的位置: 程式師世界 >> 編程語言 >  >> 更多編程語言 >> Python

Matlab to Python

編輯:Python

About matlab turn python The basic rules of the code , See : NumPy for MATLAB users
Here's a list of my matlab turn python In the process of coding , Others involved matlab function , These functions are in "NumPy for MATLAB users" There may not be .
If you think this blog , It helps you , Welcome to collect and subscribe !

matlabpythonnoted = bi2de(b,p,flg)d = bi2de(b,p,left_msb)flg='left-msb' when , left_msb=True;
flg='right-msb' when , left_msb=False.
See : bi2deCC = bwconncomp(BW,conn)CC = bwconncomp(BW,conn) See : matlab function (bwconncomp) Of python Realization Y = circshift(A, K)Y = circshift(A, K) See : circshiftw = conv(u,v,shape)w = numpy.convolve(u,v, shape)[f,x] = ecdf(y)f, x = ecdf(y) See : ecdfb = fir1(n, Wn)b = scipy.signal.firwin(n+1, Wn)y = pskmod(x,M,ini_phase)y = pskmod(x,M,ini_phase) See : pskmod

bi2de

import numpy as np
def bi2de(b: np.ndarray, p: int = 2, left_msb = False):
if left_msb == True:
b = b[::-1]
if b.ndim == 1:
d = 0
for i, bi in enumerate(b):
d += bi * (p**i)
else:
d = np.zeros(b.shape[-1])
for i, bi in enumerate(b):
d += bi * (p**i)
return d

circshift

import numpy as np
def circshift(A, K):
return np.hstack((A[-K:], A[:-K]))

ecdf

And matlab Medium ecdf Different functions , matlab in deecdf Back to f( Cumulative probability ) Is linearly increasing , there ecdf Back to x Is linearly increasing .

import numpy as np
from statsmodels.distributions.empirical_distribution import ECDF
def ecdf(y):
ecdf0 = ECDF(y)
x = np.linspace(np.min(y), np.max(y), len(y)+1)
f = ecdf0(x)
return f, x

pskmod

import numpy as np
def pskmod(x: np.ndarray, M: int, ini_phase: float = 0):
theta = 2*np.pi*x/M
y = np.exp(1j*(theta + ini_phase))
return y

  1. 上一篇文章:
  2. 下一篇文章:
Copyright © 程式師世界 All Rights Reserved