function [ykhat,n]=make_ykhat(wk,nd,phi1); %%% This function makes the 512-pt ykhat[n] pulse required by Exercise 6.5 %%% in Computer Explorations in Signals & Systems by Buck/Daniel/Singer %%% %%% This function uses the same notation as Problem 5.57 in the textbook %%% by Oppenheim/Schafer/Buck. That is, nd and phi1 are the quantities %%% defined in part b of that problem. %%% %%% Function call: [ykhat,n]=make_ykhat(wk,nd,phi1); %%% %%% Output is ykhat=x[n-nd]cos(wk*n-phi1) %%% %%% Variables: %%% wk = pulse center frequency (rad/sec) %%% nd = restricted to integer %%% phi1 = phase shift %%% ykhat = output pulse vector %%% n = vector of time indices %%% %%% Note: this function will have wrap-around problems if nd approaches %%% 512 points, which is the overall length of the pulse %%% (including zero-padding). %%% p=[hamming(75); zeros(437,1)]; n=(0:511)'; xkshift=circshift(p,nd); % use circshift to shift envelope ykhat=xkshift.*cos(wk*n-phi1); return