Help. I keep getting error messages on FFT Signal with two sinusoids (100 Hz and 200 Hz) with -10 dB.

8 visualizaciones (últimos 30 días)
I am new in matlab. This code supposed to show 3 graphs - magnitude spectrum, and phase spectrum. The problem is it wont show anything and keeps getting error messages. In this code, I want to make two sinusoids with frequencies 100 Hz and 200 Hz, with -10 dB in sine signal(I already wrote it in sig_noise).
if true
% code
% Example 3.3 Determine spectrum of a noisy waveform
N = 1024; % Data length
N2 = 511; % Valid spectral points
fs = 1000; % Sample frequency (assumed by sig_noise)
f = [100 200];
[x,t] = sig_noise(f,-10,N); % % Generate data using ‘sig_noise’(I mean it to be 100 Hz and 200 Hz sine plus white noise in -10 dB)
X = fft(x); % Calculate FFT
X_mag = abs(X); % Compute magnitude spectrum
Phase = unwrap(angle(X)); % Phase spectrum unwraped
Phase = Phase*360/(2*pi); % Convert phase to deg
f = (0:N-1)*fs/N; % Frequency vector
subplot(2,1,1);
plot(f(1:N2),X_mag(1:N2),'k'); % Plot magnitude spectrum
......Labels and title.......
subplot(2,1,2);
plot(f(1:N2),Phase(1:N2),'k'); % Plot phase spectrumy
label('Phase (deg)','FontSize',14);
......Labels and title.......
end
ps: It is supposed to show like this
<</matlabcentral/answers/uploaded_files/132613/magnitude%20spectrum%20and%20phase%20spectrum.png>>
  4 comentarios
KALYAN ACHARJYA
KALYAN ACHARJYA el 16 de Sept. de 2018
Editada: KALYAN ACHARJYA el 16 de Sept. de 2018
Is this function, inbuilt function or user-defined function? Main source link
Error
Undefined function or variable 'sig_noise'.
Venya Celeste
Venya Celeste el 16 de Sept. de 2018
actually, I've figured it out because of your question. Haha. Thank you

Iniciar sesión para comentar.

Respuestas (0)

Categorías

Más información sobre 2-D and 3-D Plots 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