Using a digital delay line with lumped parameters to model the acoustic waveguide at the heart of many different musical instruments results in highly realistic synthetic sounds. Stanford's CCRMA has been at the forefront of developing these methods, in particular through the work of Prof. Julius Smith. (Read his 1992 Computer Music Journal article, his 1996 update, and the draft of his forthcoming book on the topic.)
The original 1992 article includes C code for a simple plucked string simulation, but I wanted to be able to demonstrate it under Matlab, so I made a simple reimplementation as a .m file.
The basic usage is:
x = pluck(len, count, ref, pos, viz);
where len is the length of the two digital delay lines in samples (controlling the period of oscillation), count is the number of output samples to generate (controlling the duration of the sound), and ref (optional) defines the lumped 'loss' as an FIR filter that constitutes the reflection at one end. Optional pos defines an initial pluck point as a proportion of the total string length (or, if a vector, an initial displacement profile), and viz if specified and nonzero causes a plot of the string shape after each time step. The output sequence, x, is actually the taken as the 'lost' amplitude, and can be heard from Matlab via soundsc(x).
Try x = pluck(20,16000) as a starting point, then experiment with different values of len to change the note. Then try modifying the default ref of [-.25 -.5 -.25] to see how that changes the tone quality (but keep it negative and with an absolute sum less than one to keep the simulation behaving somewhat like a string). Also note how moving the 'pluck position' pos (and hence the initial displacement profile) affects the tone quality.
Thanks to Gary Scavone at CCRMA for sharing his Matlab implementation of the pluck algorithm with me.