% sigsynth.m
load('trumpet');
Fs = 11025;             % our sample rate is 11025 Hz
Y = fft(trumpet, 512);  % take the fft of trumpet
Ymag = abs(Y);          % take the mag of Y
f = Fs * (0:256)/512;   % get a meaningful axis 
plot(f, Ymag(1:257));   % plot Ymag (only half the points are needed)
xlabel('Frequency (Hz)')
ylabel('Magnitude')
% read from graphic a few maxima
freq=[0,258,538,796,1055,1335,1593,1852,2110,2390]; 
mag=[15.94,11.8,38,65,52,52.6,39,28.3,12.5,15.7];
N=length(freq);
t=0:1/Fs:1;
M=length(t);
myans=zeros(M,N);
for i=1:N
    myans(1:end,i)=mag(i)*cos(2*pi*freq(i)*t);
end
myans(1,:)

    