� Primjer3.m clear all close all f1=1; % FREKVENCIJA OSNOVNE KOMPONENTE f2=3; % FREKVENCIJA VISEG HARMONIKA fs=15; % FREKVENCIJA ODMJERAVANJA x=[0:1/fs:10]; % VRIJEME y=sin(2*pi*f1*x)+sin(2*pi*f2*x) ; %SIGNAL % RACUNANJE SPEKTRA SIGNALA Pin = abs(fft(y,512))/length(y); fin =fs*(0:255)/512; % NORMALIZOVANJE FREKVENCIJE y1=sin(2*pi*f1*x)+sin(2*pi*f2*x) ; %ODMJERENI SIGNAL subplot(221) stem(x(1:2*fs),y1(1:2*fs),'.') % IZGLED SIGNALA title('Odmjerci <strong>signala</strong>','FontSize',14) xlabel(' vrijeme [s]') text(<strong>1.</strong>52,<strong>1.</strong>6,['{\itf_s}=',num2str(fs),'Hz'],'FontSize',14) text(<strong>1.</strong>52,<strong>1.</strong>15,['{\itf_1}=',num2str(f1),'Hz'],'FontSize',14) text(<strong>1.</strong>52,0.5,['{\itf_2}=',num2str(f2),'Hz'],'FontSize',14) ylabel('Amplituda') grid on % RACUNANJE SPEKTRA SIGNALA Pyy =abs(fft(y1,512))/length(y1); fyy =fs*(0:511)/512; % NORMALIZOVANJE FREKVENCIJE subplot(222) plot(fyy,Pyy(1:512)) % IZGLED SPEKTRA DISKRETNOG SIGNALA title('Spektar <strong>signala</strong> nakon odmjeravanja','FontSize',14) xlabel(' frekvencija [Hz]') ylabel('Magnituda') grid on prilog n=2; p=n; q=1; l=4; %%DUZINA FILTRA alpha=0.5; %FREKVENCIJA ODSIJECANJA [z,b]=interp(y1,n,l,alpha); x2=[0:1/(n*fs):10]; subplot(223) stem(x2(1:4*fs),z(1:4*fs),'.') title(['Signal nakon interpolacije pri n = ',int2str(n)],'FontSize',14) xlabel(' vrijeme [s]') ylabel('Amplituda') text(<strong>1.</strong>51,<strong>1.</strong>55,['{\itf_s}=',num2str(fs*n),'Hz'],'FontSize',14) grid on % RACUNANJE SPEKTRA SIGNALA Pyy1 = abs(fft(z,512))/length(z); fyy1 =(p/q)*(0:511+(ceil(q/p)-1)*512)/512; % NORMALIZOVANJE FREKVENCIJE + periodicnost spektra for i=0:ceil(q/p)-1 Pyy2(512*i+1:512*(i+1))=Pyy1; end 75
a=find(fyy1