Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

A hack to create transfer-function with pure deadtime.#1032

jamestjat started this conversation inIdeas
Discussion options

def TransferFunction(num:list[float], den:list[float], deadtime: float = 0.0, dt:float=0.0) -> control.TransferFunction:    """    Creates a discrete-time transfer function with the given numerator and     denominator coefficients.    Also adds deadtime to the transfer function if given.    Parameters    ----------    num : list        Numerator coefficients of the transfer function    den : list        Denominator coefficients of the transfer function    deadtime : float, optional        Deadtime of the transfer function, by default 0    dt : float, optional        Sampling time of the transfer function, by default 0.1        Returns    -------    control.TransferFunction        Discrete-time transfer function with the given parameters        Examples    --------    >>> import matplotlib.pyplot as plt    >>> num = [0.9958683]    >>> den = [1, -0.0041317]    >>> deadtime = 5    >>> dt = 0.5    >>> Gz = TransferFunction(num, den, deadtime, dt)    >>> print(Gz.dcgain)    >>> y, t = Gz.step_response    >>> plt.title('Stepresponse (Y per U)')    >>> plt.plot(t, y, '-r')    >>> plt.xlabel('Time(min)')    >>> plt.ylabel('Amplitude')    >>> plt.grid()    >>> plt.show()    """    if dt:        Gz = control.TransferFunction(num, den, dt)    else:        Gs = control.TransferFunction(num, den)        # dt = get_dt(Gs)        dt = 0.1        Gz = control.sample_system(Gs, dt, 'tustin')    if deadtime >= 1:        deadtime_samples = int(np.ceil(deadtime/dt)) + 1        theta = np.full(deadtime_samples, 0.0)        for i in range(len(theta)):            if i % 2 != 0:                theta[i] = -0.0        denz = np.concatenate((Gz.den[0][0].flatten(), theta), axis=None)        Gz.den[0][0] = denz    return Gz
You must be logged in to vote

Replies: 0 comments

Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Category
Ideas
Labels
None yet
1 participant
@jamestjat

[8]ページ先頭

©2009-2025 Movatter.jp