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>>