Is there any easy way to handle difference equation in MATLAB ?
Afficher commentaires plus anciens
So currenlty i am working on difference equation and for example i am just taking the differnce equation as :
h(n) = 0.1δ(n) + 0.2δ(n − 2) + 0.5δ(n − 3).
what i have been doing so far is the trivial approrach of iterating over all values of n and making a vector 'h' out of that but that will become useless if the number of n goes to very large .So i am looking currently if i can have a optimistic way to get the frequency/Phase/Magnitude responses.
Thanks for your time and patience.
Réponse acceptée
Plus de réponses (1)
Hi Ram,
% Defining the coefficients of the difference equation
b = [0.1, 0.2, 0.5]; % Numerator coefficients corresponding to the equation you mentioned
a = [1]; % Denominator coefficients (default is 1)
% Compute the frequency response
[h, w] = freqz(b, a);
% Plot the magnitude response
subplot(2, 1, 1);
plot(w, abs(h));
xlabel('Frequency');
ylabel('Magnitude');
title('Magnitude Response');
% Plot the phase response
subplot(2, 1, 2);
plot(w, angle(h));
xlabel('Frequency');
ylabel('Phase');
title('Phase Response')
Catégories
En savoir plus sur Mathematics 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!

