Hello I have to build a program that is able to play some piano sounds from beethoven elise
Now I have implemented the function for the frequency and the sound but it so
As mentioned in the Comments, the sound that a piano makes is quite complicated. As such this is not a Matlab challenge, just a math problem.
Now that you know this, you 'just' need to come up with a reasonable mathematical approximation, and from here it should be straight forward to implement in Matlab.
Here is something to get you started with the math:
https://dsp.stackexchange.com/questions/46598/mathematical-equation-for-the-sound-wave-that-a-piano-makes