from Digital Guitar Tuner by Farhat Masood
This program plays the fundamental guitar strings sounds so that one could tune the respective guita

xx=sumcos(f, A, fs, dur)
function xx=sumcos(f, A, fs, dur)
%xx=sumcos(f, A, fs, dur)
%Inputs:
%   f = vector of frequencies.
%   A = Amplitude vector of complex 
%       exponentials: (Amp*exp{j*phase})
%   fs = the sampling rate in samples per second.
%   dur = time duration on the signal in seconds.
%Outputs:
%   xx = the synthesized signal.
%Note: f and A must be the same length,
%   A(1) corresponds to f(1)
%   A(2) corresponds to f(2), etc.

%Creates time vector.
t=[ 0 : 1/fs : dur ]; 

%Creates matrix of non-amplitude cosines.
M = exp( i*2*pi*( (f')*t ) );

%Prepares amplitude matrix.
A = diag(A);

%Sums the real parts of columns resulting from the 
%  matrix multiplication, which combines the 
%  cosines and amplitudes.
xx= sum( real(A * M), 1 );

%---------- END sumcos.m ---------------

Contact us at files@mathworks.com