ans = 
How do I compute impulse response?
Afficher commentaires plus anciens
How can I calculate the impulse response for the following equation:
y[n]=-5*X[n]+2*X[n-1]-5*X[n-2]+2*X[n-3]
1 commentaire
Arundhathi
le 5 Nov 2024
import numpy as np import matplotlib.pyplot as plt
- Define the system equation y[n] = -5*X[n] + 2*X[n-1] - 5*X[n-2] + 2*X[n-3]
- Define the length of the signal (let's take a range from n=0 to n=10) n = np.arange(0, 11)
- Create the impulse response using numpy's delta function delta = np.zeros_like(n, dtype=float) delta[n == 0] = 1 # Impulse signal at n=0
- Initialize the output y[n] for the impulse response h = np.zeros_like(n, dtype=float)
- Compute the impulse response for i in range(len(n)): h[i] = -5 * delta[i] + 2 * delta[i-1] - 5 * delta[i-2] + 2 * delta[i-3]
- Print the impulse response print("Impulse Response h[n]:") for i in range(len(n)): print(f"h[{n[i]}] = {h[i]}")
- Plot the impulse response plt.stem(n, h, use_line_collection=True) plt.title('Impulse Response h[n]') plt.xlabel('n') plt.ylabel('h[n]') plt.grid(True) plt.show()
Réponse acceptée
Plus de réponses (3)
Akkinapalli
le 6 Jan 2025
Modifié(e) : Walter Roberson
le 16 Fév 2025
Xt=2sin5t
x^2=5sin10t
X^3=10sin20t
1 commentaire
This is not valid MATLAB syntax. There is no implied multiplication in MATLAB, so 2sin5t is not permitted syntax. Also, sin needs to be called as a function, such as sin(5*t)
It is also not valid to have an expression on the left hand side of an = statement.
The closest to those statements that you could get in MATLAB would be
syms t Xt x X
Xt == 2*sin(5*t)
x^2 == 5*sin(10*t)
X^3 == 10*sin(20*t)
This will not have much effect, as it is a series of equations and it is not assigning the equations to variables.
Ali
le 15 Fév 2025
a=5; , x=2; , y=8;
y=exp(1)*sin(x)+10*sqrt(x)
1 commentaire
Walter Roberson
le 16 Fév 2025
This does not appear to have anything to do with the Question.
Saiyad
le 5 Déc 2025
Modifié(e) : Walter Roberson
le 5 Déc 2025
x=2
y=3
x+y
1 commentaire
Walter Roberson
le 5 Déc 2025
Please comment your code, explaining how it solves impulse result equations.
Catégories
En savoir plus sur Antennas, Microphones, and Sonar Transducers dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!

