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

3 次查看(过去 30 天)
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 个评论
KALYAN ACHARJYA
KALYAN ACHARJYA 2018-9-16
编辑:KALYAN ACHARJYA 2018-9-16
Is this function, inbuilt function or user-defined function? Main source link
Error
Undefined function or variable 'sig_noise'.

请先登录,再进行评论。

回答(0 个)

类别

Help CenterFile Exchange 中查找有关 2-D and 3-D Plots 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by