Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    New to the CF scene
    Join Date
    Nov 2018
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Question how to create graphic in matplotlib

    Hello, I have the following question that is the subject: Fundamentals of Signals and Systems,

    • Generate a MATLAB graph of the output response and y[n], for 5 <= n <= 40 of the filter
    • PMPE in point 5, with b = 0.7, when the input x[n] is:
      a) x[n] = 1, 0 <= n <=40
      b) x[n] = n, 0 <= n <= 40

    result of a)
    Code:
    import numpy as np
    from matplotlib import pyplot as plt
    N = 40
    x = np.ones(N+1)
    b = 0.7
    S = 5
    a =(1 - b) / (1-b**S)
    i = np.arange(1,S+1)
      
    w = a * (b**(S-i))
    # print(w)
    y = np.zeros(N)
    y[S-1:] = [ np.dot(w, x[n-S+1:n+1].T) for n in range(S-1, N)]
    print(y)
    print(len(y))
    plt.plot(range(S, N+1),y[S-1:], marker='o')
    plt.plot(range(S, N+1),y[S-1:], linestyle='-')
    plt.show()

    now I do not know how to do part b)
    -example-jpg

  2. #2
    New to the CF scene
    Join Date
    Nov 2018
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Well, I found the solution, it was only to make this change
    Code:
    x = np.one(N+1)
    to
    Code:
    x = np.arange(N)


 

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •