![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1755624/image.png)
Draw amplitude spectrum of filter
1 Ansicht (letzte 30 Tage)
Ältere Kommentare anzeigen
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 Kommentare
Antworten (1)
Mathy
am 19 Aug. 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:
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1755624/image.png)
Hope this helps!
0 Kommentare
Siehe auch
Kategorien
Mehr zu Octave finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!