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

### Venya Celeste (view profile)

on 16 Sep 2018
Latest activity Commented on by Venya Celeste

### Venya Celeste (view profile)

on 16 Sep 2018
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

Show 1 older comment
Venya Celeste

### Venya Celeste (view profile)

on 16 Sep 2018
Sig_noise (frequencies, magnitude in dB, N)
KALYAN ACHARJYA

### KALYAN ACHARJYA (view profile)

on 16 Sep 2018
Is this function, inbuilt function or user-defined function? Main source link
Error
Undefined function or variable 'sig_noise'.
Venya Celeste

### Venya Celeste (view profile)

on 16 Sep 2018
actually, I've figured it out because of your question. Haha. Thank you