% LPC spektralni analyza
%%%%%%%%%%%%%%%%%%%%%%%%

% 1) Analyzovany signal

frame = loadbin ( 'vm0-512.bin' ) ;

% Vypocet parametru AR modelu
p=10;
[a, Ep]=lpc(frame,p);


%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Posouvat tento blok s funkci return pro postupne zpracovani

return
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%


% 1) Filtrace generujici chybovy signal

figure(1) ;

subplot(211) ;
plot(frame) ;
title('Originalni signal')

en=.....

subplot(212)
plot(en)
title('Chybovy signal') ;


% 2) Modelovani s buzenim chybovym signalem

figure(2) ;

subplot(211) ;
plot(en) ;
title('Buzeni AR modelu - chybovy signal')

y1=.......

subplot(212)
plot(y1,'r')
hold on
plot(frame,'--')
hold off
title('Modelovany a puvodni signal') ;

% 3) Modelovani s buzenim generovanymi pulzy

figure(3) ;

To=120 ;
un=[1 zeros(1,To-1) 1 zeros(1,To-1) 1 zeros(1,To-1) 1 zeros(1,To-1) 1 zeros(1,To-1)] ;


subplot(211) ;
plot(un) ;
title('Buzeni AR modelu - chybovy signal')

y2=.....

subplot(212)
plot(y2,'r')
hold on
plot(frame,'--')
hold off
title('Modelovany a puvodni signal') ;


% 4) Modelovani s buzenim generovanymi pulzy s jednotkovym vykonem

figure(4) ;

un2=.......


subplot(211) ;
plot(un2) ;
title('Buzeni AR modelu - chybovy signal')

y3=filter(sqrt(Ep),a,un2) ;

subplot(212)
plot(y3,'r')
hold on
plot(frame,'--')
hold off
title('Modelovany a puvodni signal') ;



