% plotspa.m  m-file function to plot waveforms 

  function plotspa(wavetype,t,y,Amp,off,phase,nwave,FAmp,f1,fn,freq,T,sig)

v = [0 max(t) min(y) max(y)];
clf;
subplot(211),plot(t,y,'k-','linewidth',0.5); hold on; plot(t,y,'*','markersize',3);
axis(v)
ttle = ['Sample Points from Waveform: ' wavetype];
title(ttle)
ylabel('Input Signal')
xlabel('time (sec)')

maxay = max(FAmp);
va=[0 fn 0 maxay+maxay/10];
subplot(212),bar(freq,FAmp)
axis(va)
xlabel('frequency (Hz)')
ylabel('Fourier Amplitude Coef')
vari = std(y)*std(y);
%vari = (FAmp.*FAmp)/2;

if nwave==2
 title([' Mean= ',num2str(off),' variance= ',num2str(vari)])
elseif nwave==1
 title(['Period=',num2str(T),' Phase= ',num2str(phase),' Amp= ',num2str(Amp),' Mean= ',num2str(off),' variance= ',num2str(vari)])
else
 title(['    '])
end

signature(sig,'OC3150 Lab 3');

strike=('Strike any key to continue');
disp(strike)

pause

