Draw amplitude spectrum of filter

4 visualizaciones (últimos 30 días)
Hoa Luong
Hoa Luong el 8 de Nov. de 2022
Respondida: Amith el 19 de Ag. de 2024
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, ...)

Respuestas (1)

Amith
Amith el 19 de Ag. de 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!

Categorías

Más información sobre Octave en Help Center y File Exchange.

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by