Generate Frequency Spectrum
Versión 1.0.0 (1,15 KB) por
Safwan Mahmoud
Can be used to generate a complex frequency spectrum from the amplitude and phase(angle) arrays.
Let's generated an amplitude and phase array of a 60Hz using a gaussian function
f = 0:1/10:100; % Time vector
f0 = 15; % Base frequency
f1 = 30; % Peak frequency
sigma = 1; % Standard deviation of the Gaussian
mag = f0 + (f1 - f0) * exp(-((f - 60).^2) / (2 * sigma^2));
angleArray = f;
subplot(211)
plot(f,mag)
xlabel('Frequency (Hz)');
ylabel('Amp');
title('Magnitude');
grid on;
subplot(212)
plot(f,angleArray)
xlabel('Frequency (Hz)');
ylabel('Angle');
title('Phase');
grid on;
Now Let's apply the Generate spectrum function
spec = genSpectrum(mag, angleArray);
clf
subplot(211)
plot(f,abs(spec))
xlabel('Frequency (Hz)');
ylabel('Amp');
title('Magnitude');
grid on;
subplot(212)
plot(f,angle(spec))
xlabel('Frequency (Hz)');
ylabel('Angle');
title('Phase');
grid on;
Note: the angle will look different without unwrapping it first.
Citar como
Safwan Mahmoud (2025). Generate Frequency Spectrum (https://es.mathworks.com/matlabcentral/fileexchange/169707-generate-frequency-spectrum), MATLAB Central File Exchange. Recuperado .
Compatibilidad con la versión de MATLAB
Se creó con
R2023b
Compatible con cualquier versión
Compatibilidad con las plataformas
Windows macOS LinuxEtiquetas
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!Descubra Live Editor
Cree scripts con código, salida y texto formateado en un documento ejecutable.
| Versión | Publicado | Notas de la versión | |
|---|---|---|---|
| 1.0.0 |
