Documente Academic
Documente Profesional
Documente Cultură
1. Program a matlab function that generates sinusoidal signal. Using the function programmed generate a signal consisting of sum of n sinusoids. 3. Try different visualizations 4. Estimate PDF of the signals (hist) 5. Some extra exercises 6. Add to sinusoidal signal white noise generated by randn. Visualize the result with different signal to noise ratios S/N = [100 10 1 0.1] 7. Create simple digital filter using Signal Processing Toolbox 8. Use filtering to get better signal to noise ratio 9. Do 7. and 8. using MATLAB Signal Procesing Toolbox GUI sptool.
%Exercise on singlans and filters for course MIT-1210 %Script by Matti Jukola (SH101) %2009.10.13
%Q: Visualize the result by plotting. plot(t,x,'.-') title('Sinusoidal signal'); xlabel('Time') ylabel('Amplitude')
n = n_arr(ii); f = 10 + 10*rand(n,1); a = 0.5 + rand(n,1); p = 2*pi*rand(n,1); syms xs; %Clear x for jj = 1:n xs = xs+sinsig(ts,f(jj),a(jj),p(jj)); end figure ezplot(xs, [0 2 -1*n 1*n]) %Plot signal from t = 0 to 2 and y axis from -1*n to 1*n title(sprintf('Sinusoidal signal with %d components', n)); xlabel('Time') ylabel('Amplitude') end
for ii = 1:numel(n_arr) n = n_arr(ii); f = 10 + 10*rand(n,1); a = 0.5 + rand(n,1); p = 2*pi*rand(n,1); x = zeros(size(t)); for jj = 1:n x = x+sinsig(t,f(jj),a(jj),p(jj)); end figure hist(x,round(sqrt(numel(x)))); %Histogram with sqrt(numel(x)) bins title(sprintf('Histogram of sinusoidal signal with %d components', n)); xlabel('Bin centers') ylabel('Bin counts') end
f = 0.4; x = sinsig(t,f,a,p); f = 0.1; x = x .* sinsig(t,f,a,p); plot(t,x,'.-') title('Sinusoidal signal (amplitude modulation)'); xlabel('Time') ylabel('Amplitude')
6. Add to sinusoidal signal white noise generated by randn. Visualize the result with different signal to noise ratios S/N = [100 10 1 0.1]
samp_rate = 0.05; t = 0:samp_rate:10; f = 0.4; x = sinsig(t,f,a,p); SN_arr = [100 10 1 0.1]; for ii = 1:numel(SN_arr) SN = SN_arr(ii); xn = x+randn(size(x))*(1/SN); figure plot(t,xn,'.-') title(sprintf('Sinusoidal signal + noise. S/N = %f', SN)); xlabel('Time') ylabel('Amplitude') end
% % % %
-Select both signal ('sig1') and filter ('filt1') from the lists -Click button 'Apply' under 'Filters' -Now window appears, click 'Ok' -Select new signal and click button 'View' under 'Signals'