Draw amplitude spectrum of filter
4 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
i want to draw a amplitude spectrum of filter that has an amplitude of 5 in the range [0, 1] ; -20 (dB/octave) attenuation in
(1,6] and -60 (dB/octave) in the range (6, ...)
0 commentaires
Réponses (1)
Amith
le 19 Août 2024
Hi Hoa Luong,
Find the MATLAB code below according to the specification requested where there is an amplitude of 5 in the range [0, 1], -20 dB/octave attenuation in the range (1, 6], and -60 dB/octave attenuation in the range (6, …):
% Define the frequency range
f = logspace(-1, 2, 1000); % Frequency range from 0.1 to 100 Hz
% Initialize the amplitude spectrum
A = zeros(size(f));
% Define the amplitude spectrum
A(f <= 1) = 5; % Amplitude of 5 in the range [0, 1]
A(f > 1 & f <= 6) = 5 * (f(f > 1 & f <= 6) / 1).^(-20/20); % -20 dB/octave attenuation in (1, 6]
A(f > 6) = 5 * (6 / 1).^(-20/20) * (f(f > 6) / 6).^(-60/20); % -60 dB/octave attenuation in (6, ...)
% Plot the amplitude spectrum
figure;
semilogx(f, A, 'LineWidth', 2);
xlabel('Frequency (Hz)');
ylabel('Amplitude');
title('Amplitude Spectrum of the Filter');
grid on;
The graph yielded from the above MATLAB code is:
Hope this helps!
0 commentaires
Voir également
Catégories
En savoir plus sur Octave dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!